---
"@context": https://mx.allabout.network/canon/context.json
title: "MX Carrier Formats specification"
description: "This specification specifies how MX metadata is carried across file formats. It covers two layers:"
author: "Tom Cranstoun"
created: "2026-10-02"
modified: "2026-11-28"
type: "reference"
mx:
  mxSpecVersion: "0.9"
  canonicalUri: https://mx.allabout.network/specs/carrier-formats.md
  servedAt: https://mx.allabout.network/specs/carrier-formats.md
  audience: [humans, machines]
  contentPolicy: "MX specification page: MX Carrier Formats specification. AI agents may cite, summarize, link to, and quote."
  stability: "stable"
  x-mx-contentState: "published"
  contextProvides:
    - "This specification specifies how MX metadata is carried across file formats. It covers two layers:"
  runbook: "Generated from the page's draft-site source; never edit this file. Change the source and regenerate the page, and this twin is rebuilt beside it."
  purpose: "The markdown version of https://mx.allabout.network/specs/carrier-formats.html, built from its source: the same text as the page, without its navigation or footer."
cps:
  record: urn:uuid:229390e2-939a-5492-ab9a-8cfd099fb612
  signedDocument: https://mx.allabout.network/specs/carrier-formats.html
  contentHash: sha256:82a803de514d36a2abc84363214f4c61d4e8b09171b66095e41f6b4cce50f727
---

> This is the markdown version of https://mx.allabout.network/specs/carrier-formats.html. For the site index, see [llms.txt](https://mx.allabout.network/llms.txt).

# MX Carrier Formats specification

**Version:** 1.2
**Status:** MX specification, maintained by CogNovaMX
**Date:** 2 October 2026
**Author:** Tom Cranstoun
**License:** MIT

---

## 1. Abstract

This specification specifies how MX metadata is carried across file formats. It covers two layers:

1. **Carrier mechanisms** - the syntactic envelope each file format uses to host MX metadata: YAML frontmatter for markdown, `<meta>` tags for HTML, JSDoc comments for JavaScript, CSS comments, shell comment blocks, XMP for media, sidecar files, and SQL comment blocks.
2. **Code-specific provenance vocabulary** - a minimum viable set of fields specific to source code as a document and not covered by the universal identity vocabulary, and a mod vocabulary for code a host application loads into its own event loop.

The note also defines the `mx:*` identity fields used by carriers that do not have YAML frontmatter (HTML, JavaScript, CSS).

What the code does - function signatures, API surfaces, test metadata, type systems, invariants, behaviour - is explicitly out of scope. Each language already has its own convention for this (JSDoc, Python docstrings, Doxygen, rustdoc, godoc). MX does not duplicate them.

Database-content vocabulary and media-content vocabulary are also out of scope; this specification specifies only how a document of either kind carries the universal MX identity fields. The MX framework reuses existing standards for the content layer:

- **Databases** - defer to [DCAT v3](https://www.w3.org/TR/vocab-dcat-3/) (datasets, distributions, catalogues), [CSVW](https://www.w3.org/TR/tabular-metadata/) (tabular schemas, columns, keys), and [Dublin Core](https://www.dublincore.org/specifications/dublin-core/dcmi-terms/) (dataset identity).
- **Media** - defer to [Schema.org](https://schema.org/) (`ImageObject`, `VideoObject`, `AudioObject`, `CreativeWork`, `license`) and the native embedded-metadata standards (EXIF, IPTC, XMP, ID3).
- **Code behaviour** - defer to the language's own documentation convention.

---

## 2. Conformance

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC 2119](https://www.rfc-editor.org/rfc/rfc2119).

Field definitions in this specification conform to the **MX Field Definition Pattern specification**. That pattern governs the structural template for every field - heading, property table, definition prose, example - and is binding on this specification. This specification adopts the pattern's authoring rules and does not restate them.

### 2.1 Conformance levels

This specification defines three conformance levels (modelled on the [WCAG 2.1](https://www.w3.org/TR/WCAG21/) Level A/AA/AAA pattern):

| Level | Name | Requirement |
|-------|------|-------------|
| Level 1 | **MX Core** | Universal identity fields present (`title`, `author`, `created`, `description`); the carrier syntax for the file's format is used correctly. |
| Level 1 / Level 2 | Zone 1b OKF surface MUST be present at all levels: `type`, `tags`, and `resource` (when applicable) are required unconditionally. MX is an OKF implementation; these fields are not optional extras - they are the OKF layer every external tool reads. Zone 2 operational fields (`status`, `license`, etc.) are added per the MX conformance ladder. |
| Level 3 | **MX Complete** | Adds Level 2 plus the code-specific provenance fields in §5 where they apply, and any `MAY`-level identity fields. |

A document claiming conformance at a given level MUST satisfy all requirements at that level and all lower levels.

### 2.2 Selective adoption

An implementation is **carrier-conformant at Level N** if, for every artefact it emits, it satisfies the Level-N requirements for the artefact's carrier format. Implementations MAY claim conformance for a subset of carriers (e.g. markdown and HTML only).

### 2.3 Baseline identity contract

Every MX-aware document, regardless of carrier, carries the universal Level 1 identity contract:

- `title` - REQUIRED
- `author` - REQUIRED
- `created` - REQUIRED (ISO 8601 date format YYYY-MM-DD)
- `description` - RECOMMENDED

The carrier-specific syntax for these fields is defined in §3.

### 2.4 Database and media content conformance

For dataset, table, column, image, video, and audio content metadata, implementations look to the external standards cited in §1. MX makes no conformance claim for content vocabularies beyond the carrier mechanisms in §3.

### 2.5 Draft status

This specification is maintained by CogNovaMX as part of MX. It is not a Gathering proposal. A change to its text is published as a new version, and implementations SHOULD note the version they implemented against.

---

## 3. Carrier format mappings

This section defines how each supported file format carries MX metadata.

### 3.1 Markdown - YAML frontmatter

| Property | Value |
|----------|-------|
| **File types** | `.md`, `.mx.yaml.md` |
| **Carrier mechanism** | YAML frontmatter between `---` delimiters |
| **Field naming** | camelCase (operational fields under `mx:` object) |
| **Conformance** | MUST (Level 1) for all markdown-based MX documents |

The primary carrier format. All MX-aware markdown documents carry metadata in YAML frontmatter using a three-zone model. MX is an OKF implementation; Zone 1b fields are required unconditionally so any OKF tool reads MX files without adaptation: Zone 1a (top-level) for document identity (`title`, `description`, `author`, `created`, `modified`, `version`); Zone 1b (top-level) for the OKF-reserved surface (`type` MUST, `tags` MUST, `resource` MUST when describing an external asset); Zone 2 (under the `mx:` object) for MX-operational fields. Implementations MUST NOT place Zone 1a or Zone 1b fields inside the `mx:` object, and MUST NOT place Zone 2 fields at the top level.

**Example:**

```yaml
---
title: "Document Title"
description: "Brief summary"
author: "Author Name"
created: 2026-04-02
modified: 2026-04-16
version: "1.0"
type: guide
tags: [metadata, example]

mx:
  status: active
  canonicalUri: https://example.com/docs/title
---
```

Extension fields appear inside the `mx:` object alongside standard operational fields. OKF-reserved fields (`type`, `tags`, `resource`) remain at the top level.

---

### 3.2 HTML - `<meta>` tags

| Property | Value |
|----------|-------|
| **File types** | `.html` |
| **Carrier mechanism** | `<meta name="mx:*">` tags in `<head>`, `data-mx-*` attributes on elements |
| **Field naming** | camelCase with `mx:` prefix (the field's own name) |
| **Conformance** | MUST (Level 2) for HTML documents claiming MX conformance |
| **Required fields** | `description` (standard HTML meta) + `author` (standard HTML meta) + the four MUST-at-Level-2 mx: meta tags listed below |

HTML documents carry MX metadata using `<meta>` tags in the document `<head>`. The `mx:` prefix in the `name` attribute distinguishes MX metadata from standard HTML meta tags.

#### 3.2.1 Naming and conversion (Normative)

The conversion from a YAML field name to its HTML carrier form is binding:

1. Keep the camelCase YAML name unchanged; the name is the field.
2. Prepend `mx:`.
3. Place the value in a `<meta name="…" content="…">` tag inside the document's `<head>`.

For example, `mx.canonicalUri: https://example.org/x` becomes `<meta name="mx:canonicalUri" content="https://example.org/x">`. The mapping is the same in both directions: a verifier reading an HTML carrier strips the `mx:` prefix from `mx:canonicalUri` to get `canonicalUri` and compares strings with the frontmatter; no case conversion is performed in either direction.

The MX Extensions specification §7.1 provides the same table as an informative summary; this subsection is the binding form. If a row in that summary disagrees with this subsection, this subsection wins.

#### 3.2.2 Required mx: meta tags at Level 2 (Normative)

An HTML document claiming MX Standard (Level 2) MUST declare the four MUST-at-Level-2 fields from MX Core Metadata specification §7a as `mx:` meta tags. Each tag MUST be present in `<head>`; absence of any one places the document at Level 1, not Level 2.

| YAML field | HTML meta tag | Value semantics (cross-reference) |
|------------|---------------|-------------------------------------|
| `mx.canonicalUri` | `<meta name="mx:canonicalUri" content="…">` | URI of the canonical version of this document. MUST agree with `<link rel="canonical">` if both are present (MX Core Metadata §7a.1). |
| `mx.summary` | `<meta name="mx:summary" content="…">` | One-to-two-sentence machine-summary; lets agents decide relevance without reading the body. |
| `mx.conformsTo` | `<meta name="mx:conformsTo" content="…">` | Comma-separated list of standards URIs the document conforms to (`mx.conformsTo` is an array; serialise as comma-separated string). |
| `mx.trainingDataPolicy` | `<meta name="mx:trainingDataPolicy" content="…">` | Whether the document may be included in AI training corpora. |

**Worked example (Normative):**

```html
<head>
  <title>Auth design notes</title>
  <link rel="canonical" href="https://example.org/blog/auth-design">
  <meta name="description" content="Working notes on the authentication redesign.">
  <meta name="author" content="Tom Cranstoun">

  <meta name="mx:canonicalUri" content="https://example.org/blog/auth-design">
  <meta name="mx:summary" content="Working notes on the authentication redesign — what we kept, what we replaced, why.">
  <meta name="mx:conformsTo" content="https://mx.allabout.network/cog.html">
  <meta name="mx:trainingDataPolicy" content="Permitted with attribution.">

  <meta name="mx:status" content="published">
  <meta name="mx:contentType" content="info-doc">
</head>
```

#### 3.2.3 Other rules

- Standard HTML meta tags (`description`, `author`) MUST use their native HTML names without the `mx:` prefix.
- MX-specific fields MUST use the `mx:` prefix in the `name` attribute.
- Array values MUST be serialised as comma-separated strings.
- `data-mx-*` attributes MAY be used on body elements for element-level MX metadata.
- The values of `<link rel="canonical">` and `<meta name="mx:canonicalUri">` MUST agree when both are present, per MX Core Metadata §7a.1; verifiers MAY treat either as authoritative.

---

### 3.3 JavaScript - JSDoc comments

| Property | Value |
|----------|-------|
| **File types** | `.js`, `.mjs`, `.ts` |
| **Carrier mechanism** | JSDoc `/** */` block with `@mx:` tags |
| **Field naming** | camelCase with `@mx:` tag prefix (the field's own name) |
| **Conformance** | MUST (Level 2) for JavaScript documents claiming MX conformance |
| **Required fields** | `@description` + `@version`/`@author` + at least one `@mx:*` tag |

JavaScript files carry MX metadata in a JSDoc comment block at the top of the file. MX-specific fields use the `@mx:` tag prefix.

**Example:**

```javascript
/**
 * @description MX validation utility
 * @version 1.0
 * @author Tom Cranstoun
 * @mx:status active
 * @mx:contentType utility
 * @mx:runtime node
 * @mx:tags validation, metadata
 */
```

- Standard JSDoc tags (`@description`, `@version`, `@author`) MUST use their native JSDoc names.
- MX-specific fields MUST use the `@mx:` prefix.
- The JSDoc block SHOULD appear at the top of the file, before any code.

---

### 3.4 CSS - comments

| Property | Value |
|----------|-------|
| **File types** | `.css` |
| **Carrier mechanism** | CSS comment `/* */` block with `@mx:` tags |
| **Field naming** | camelCase with `@mx:` tag prefix (the field's own name) |
| **Conformance** | MUST (Level 2) for CSS documents claiming MX conformance |
| **Required fields** | `@description` + `@version`/`@author` + at least one `@mx:*` tag |

CSS files carry MX metadata in a comment block at the top of the file. MX-specific fields use the `@mx:` tag prefix.

**Example:**

```css
/*
 * @description Global layout styles
 * @version 2.0
 * @author Tom Cranstoun
 * @mx:status active
 * @mx:type utility
 * @mx:tags layout, responsive
 */
```

The metadata comment block SHOULD appear at the top of the file, before any rules.

---

### 3.5 Image - EXIF/XMP metadata

| Property | Value |
|----------|-------|
| **File types** | `.png`, `.jpg`, `.webp`, `.svg` |
| **Carrier mechanism** | EXIF/XMP metadata with `mx:` namespace |
| **Field naming** | `mx:` namespace prefix, original case preserved |
| **Conformance** | MAY (Level 3) |

Image files carry MX identity metadata in EXIF/XMP metadata blocks using the `mx:` XML namespace. When XMP embedding is not practical, a sidecar file (`.mx.yaml`) SHOULD be used instead. Image-content vocabulary (subject, alt text, EXIF camera fields) is governed by EXIF/IPTC/XMP/Schema.org and is not redefined here.

**Example (XMP):**

```xml
<rdf:Description xmlns:mx="https://allabout.network/ns/mx/1.0">
  <mx:type>illustration</mx:type>
  <mx:status>active</mx:status>
</rdf:Description>
```

The MX XMP namespace URI is `https://allabout.network/ns/mx/1.0`.

---

### 3.6 Shell scripts - comment block

| Property | Value |
|----------|-------|
| **File types** | `.sh`, `.bash`, `.zsh` |
| **Carrier mechanism** | `# ---` YAML block with `#` prefix on each line |
| **Field naming** | camelCase in `# key: value` lines |
| **Conformance** | MUST (Level 2) for shell scripts claiming MX conformance |
| **Required fields** | `title`, `description`, `status`, `author` |

Shell scripts carry MX metadata in a comment block using `# ---` delimiters, with each YAML line prefixed by `#`.

**Example:**

```bash
#!/bin/bash
# ---
# title: "Build and deploy"
# description: "Builds site artefacts and deploys to Cloudflare"
# author: "Tom Cranstoun"
# type: script
# status: active
# ---
```

- The metadata block MUST start and end with `# ---`.
- Field names use camelCase, matching YAML conventions.
- The metadata block SHOULD appear immediately after the shebang line.

---

### 3.7 `.mx.yaml` - media sidecar

| Property | Value |
|----------|-------|
| **File types** | `.mx.yaml` (placed alongside a media asset) |
| **Carrier mechanism** | Standalone YAML file |
| **Field naming** | camelCase |
| **Conformance** | MAY (Level 3) |

A sidecar metadata file placed alongside a media asset (image, video, audio, binary) that cannot carry embedded metadata. The sidecar file name matches the asset file name with `.mx.yaml` appended.

**Example (for `hero-image.webp`):**

File: `hero-image.webp.mx.yaml`

```yaml
title: "Hero banner image"
description: "Full-width hero image for the landing page"
author: "Tom Cranstoun"
created: 2026-04-02
modified: 2026-04-16
type: image
tags: [hero, banner, landing]

mx:
  status: active
```

The sidecar file MUST use the three-zone model and the file name MUST match the asset file name with `.mx.yaml` appended.

---

### 3.8 `mx.yaml` - code repository root

| Property | Value |
|----------|-------|
| **File types** | `mx.yaml` (at repository root) |
| **Carrier mechanism** | Standalone YAML file |
| **Field naming** | camelCase |
| **Conformance** | MAY (Level 3) |

A repository-level metadata file placed at the root of a code repository. Provides MX metadata for the repository as a whole.

**Example:**

```yaml
title: "MX Hub"
description: "Central hub for Machine Experience development"
author: "Tom Cranstoun"
created: 2026-01-15
modified: 2026-04-16
type: repository
tags: [hub, mx, repository]

mx:
  status: active
  domain: machine-experience
```

---

### 3.9 Database sidecars and inline SQL

| Property | Value |
|----------|-------|
| **File types** | `mx.database.yaml` (sidecar), `.sql` (inline) |
| **Carrier mechanism** | Standalone YAML sidecar or `-- @mx ... -- @mx:end` comment blocks in SQL |
| **Field naming** | camelCase |
| **Conformance** | MAY (Level 3) |

Database schemas carry MX identity metadata either in a standalone sidecar file (`mx.database.yaml`) or in inline SQL comments using the `-- @mx` / `-- @mx:end` delimiters. Database-content vocabulary (table relationships, column types, dataset semantics) is governed by DCAT, CSVW, and Dublin Core and is not redefined here.

**Example (sidecar):**

File: `mx.database.yaml`

```yaml
title: "Customer database schema"
description: "Schema metadata for the customer CRM database"
author: "Tom Cranstoun"

type: database-schema
mx:
  status: active
  domain: crm
```

**Example (inline SQL):**

```sql
-- @mx
-- title: Customer contacts table
-- description: Primary contact records for CRM
-- type: database-table
-- status: active
-- @mx:end
CREATE TABLE contacts (
    id INTEGER PRIMARY KEY,
    name TEXT NOT NULL
);
```

- Inline SQL metadata blocks MUST start with `-- @mx` and end with `-- @mx:end`.
- Each field line within the block MUST be prefixed with `--`.
- Field names use camelCase.

---

### 3.10 Field-form precedence (Normative)

A single MX field can appear in more than one form on the same artefact: a markdown file with a YAML frontmatter; an HTML page with both YAML frontmatter and `<meta name="mx:*">` tags; a tagged PDF carrying YAML in its document and the same fields in an XMP packet; a cog carrying both a magic-header HTML comment and a `cogHeader` frontmatter object. When multiple forms declare the same field, implementations MUST resolve them using the precedence below:

1. **YAML frontmatter** is highest precedence. When a field is declared in YAML frontmatter, the YAML value is authoritative for that field on that artefact.
2. **Carrier-specific embedded form** is next. This includes XMP for media (§3.5), the magic-header HTML comment for cogs (MX Cogs specification §4), and any other format-native packet whose declarations are intended as authoritative within that carrier.
3. **HTML `<meta>` tags** and equivalent declarative tags (JSDoc `@mx:`, CSS `@mx:` comment, SQL `-- @mx`) are next. Their values are authoritative when no higher form declares the same field on the same artefact.
4. **Inferred values** (defaulted by the validator, computed from other fields, derived from external context) are lowest. A higher form always wins over an inferred value.

When a field is declared in two or more forms on the same artefact, the values MUST agree. Disagreement is a conformance failure: tools cannot reconcile two contradictory authoritative declarations and SHOULD surface the conflict rather than silently picking one. The most common collision in practice is `<link rel="canonical">` versus `<meta name="mx:canonicalUri">` on the same HTML page (see §3.2.2 and MX Core Metadata §7a.1) - those two MUST agree.

**Author's checklist when more than one form is in play:**

- Pick the highest-precedence form available for the carrier (YAML if the carrier supports it; otherwise the carrier-specific embedded form; otherwise `<meta>` tags).
- If a second form is declared (perhaps because tooling needed both), copy the value from the higher-precedence form rather than drafting it independently. Drift between forms is a conformance failure waiting to happen.
- Verifiers SHOULD report the resolved precedence path so a downstream consumer can audit which form they relied on.

---

## 4. Non-YAML identity fields

The following fields provide MX identity and classification metadata in carrier formats that do not use YAML frontmatter (HTML, JavaScript, CSS, image XMP). All fields use the `mx:` namespace prefix in their respective carrier contexts.

When a field has a YAML equivalent (e.g. `title`, `type`, `tags`), the YAML form is used in YAML-bearing carriers and the `mx:*` form is used elsewhere. The two are aliases for the same semantic field. OKF-reserved Zone 1b fields (`type`, `tags`, `resource`) use no `mx:` prefix in non-YAML carriers - they are expressed as bare attributes following their OKF names.

### 4.1 `mx:name`

| Property | Value |
|----------|-------|
| **Type** | string |
| **Profile** | html, js, css |
| **Conformance** | SHOULD (Level 2) |

Cog name, equivalent to `title` in YAML. Provides a machine-readable identifier in carrier formats that lack YAML frontmatter.

```html
<meta name="mx:name" content="validation-utility">
```

```javascript
/** @mx:name validation-utility */
```

### 4.2 `mx:version`

| Property | Value |
|----------|-------|
| **Type** | string |
| **Profile** | html, js, css |
| **Conformance** | SHOULD (Level 2) |

Version string, equivalent to `version` in YAML.

```html
<meta name="mx:version" content="2.0">
```

```css
/* @mx:version 2.0 */
```

### 4.3 `mx:type`

| Property | Value |
|----------|-------|
| **Type** | string |
| **Profile** | html |
| **Conformance** | SHOULD (Level 2) |

Document type classification. Carries the same vocabulary as the Zone 1b `type` field in YAML frontmatter. In HTML, OKF-reserved Zone 1b fields use no `mx:` prefix - the bare `type` name is used directly, matching their top-level YAML position.

```html
<meta name="type" content="guide">
```

### 4.4 `mx:purpose`

| Property | Value |
|----------|-------|
| **Type** | string |
| **Profile** | js, css |
| **Conformance** | MAY (Level 3) |

Why this file exists. Equivalent to `purpose` in YAML.

```javascript
/** @mx:purpose validation */
```

```css
/* @mx:purpose layout */
```

### 4.5 `mx:audience`

| Property | Value |
|----------|-------|
| **Type** | string |
| **Profile** | js, css |
| **Conformance** | MAY (Level 3) |

Intended readership. Equivalent to `audience` in YAML. Array values are expressed as a comma-separated string.

```javascript
/** @mx:audience developers, agents */
```

### 4.6 `mx:stability`

| Property | Value |
|----------|-------|
| **Type** | string |
| **Profile** | js, css |
| **Conformance** | MAY (Level 3) |
| **Valid values** | stable, evolving, experimental, deprecated, archived |

Stability level. Communicates how reliable this file's interface is for external consumers.

- `stable` - interface is fixed; breaking changes require a major version bump.
- `evolving` - interface may change; consumers should pin versions.
- `experimental` - interface is subject to significant change without notice.
- `deprecated` - interface is scheduled for removal; consumers should migrate.
- `archived` - interface is no longer maintained.

```javascript
/** @mx:stability stable */
```

### 4.7 `mx:category`

| Property | Value |
|----------|-------|
| **Type** | string |
| **Profile** | html, js, css |
| **Conformance** | MAY (Level 3) |

Cog category, equivalent to `category` in YAML. Determines registry grouping in non-YAML carrier formats.

```html
<meta name="mx:category" content="mx-tool">
```

### 4.8 `mx:tags`

| Property | Value |
|----------|-------|
| **Type** | string |
| **Profile** | html, js, css |
| **Conformance** | MAY (Level 3) |

Discovery keywords as a comma-separated string. Equivalent to `tags` (array) in YAML. Values SHOULD be lowercase strings.

```html
<meta name="mx:tags" content="validation, metadata, utility">
```

### 4.9 `mx:buildsOn`

| Property | Value |
|----------|-------|
| **Type** | string |
| **Profile** | js, css |
| **Conformance** | MAY (Level 3) |

Context dependencies as a comma-separated list of cog names. Equivalent to `buildsOn` (array) in YAML. Field names use camelCase in every carrier (a recorded naming decision); the carrier syntax determines only how the value is encoded, not how the name is spelled.

```javascript
/** @mx:buildsOn fields, cog-unified-spec */
```

### 4.10 `mx:documentedIn`

| Property | Value |
|----------|-------|
| **Type** | string |
| **Profile** | js, css |
| **Conformance** | MAY (Level 3) |

Path to companion documentation. Links a code file to its narrative documentation.

```javascript
/** @mx:documentedIn ../docs/validation-guide.md */
```

### 4.11 `mx:contextProvides`

| Property | Value |
|----------|-------|
| **Type** | string |
| **Profile** | js, css |
| **Conformance** | MAY (Level 3) |

What context this file provides to agents. Declares the knowledge or capability an agent gains by reading this file.

```javascript
/** @mx:contextProvides Field validation rules and error message templates */
```

---

## 5. Code-specific provenance vocabulary

This section adds two fields specific to source code as a document, and four for mods (§5.4). They are not covered by the universal identity vocabulary or by the language's own documentation convention.

### 5.1 Fields

| Field | Type | Required | Purpose |
|-------|------|----------|---------|
| `sourceRepo` | string | OPTIONAL | URL or path of the source-control repository that holds this code file's authoritative history. Aligns with [Schema.org `codeRepository`](https://schema.org/codeRepository). |
| `derivedFromCommit` | string | OPTIONAL | Version-control commit identifier (typically a git SHA) that this artefact was derived from. Pairs with a generic `derivedFrom` provenance pointer to add commit-level specificity. |

Every other concern that a wider draft might cover - function annotations, API surface, test metadata, class invariants, dependency declarations, runtime config, build conventions - is either out of scope entirely (deferred to the language convention) or handled generically by universal identity fields.

### 5.2 Carrier syntax

Code carriers use the native metadata mechanism of their file format. Field names are identical across all carriers; only the host syntax changes.

| Carrier | Native mechanism | Example |
|---------|------------------|---------|
| JavaScript / TypeScript | JSDoc comments | `@mx:sourceRepo https://github.com/example/repo` |
| CSS | CSS block comments | `/* @mx:sourceRepo https://github.com/example/repo */` |
| Shell | Shell comment block | `# sourceRepo: https://github.com/example/repo` (after shebang) |
| SQL | SQL comment block | `-- @mx sourceRepo: https://github.com/example/repo` |
| Any | YAML frontmatter in markdown files | `sourceRepo: https://github.com/example/repo` |

A JavaScript file declaring `@mx:sourceRepo` and a markdown file with `sourceRepo:` in its YAML frontmatter carry the same semantic value.

### 5.3 Profile

This specification declares a single profile for code: `code`. An implementation handling code artefacts applies the `code` profile's fields in addition to the universal identity fields. There are no per-language sub-profiles - the vocabulary is language-agnostic.

### 5.4 Mod vocabulary

A mod is code that a host application loads into its own event loop, where it can observe what happens, rewrite an action before the host takes it, or answer in the host's place. A plugin for an AI coding agent that hooks the agent's tool calls is the common case. Such code sits between what an agent decides and what the machine does, so it declares what it hooks, what it may touch, and what it promises. This specification declares a second profile, `code-mod`, with four fields.

| Field | Type | Required | Purpose |
|-------|------|----------|---------|
| `modHooks` | array | REQUIRED | Each host event the mod hooks, as a hook string in the canonical form defined below, with the matcher list omitted when the hook takes every event. The move is `observe` (passes the event on unchanged), `rewrite` (passes on a changed event) or `answer` (returns without passing it on). |
| `modCapabilities` | array | REQUIRED | The host API surfaces the mod's code uses, in the host's own names. |
| `modGuarantee` | string | OPTIONAL | One sentence stating what the mod promises and what it explicitly does not. A machine reads it as a declared limit. |
| `testedWith` | string | OPTIONAL | The host and version the mod was last tested against, written `host@version`. |

**Hook string (Normative).** Each `modHooks` entry MUST match this grammar, written in ABNF ([RFC 5234](https://www.rfc-editor.org/rfc/rfc5234)), with `unreserved` and `pct-encoded` as defined in [RFC 3986](https://www.rfc-editor.org/rfc/rfc3986) section 2:

```abnf
mod-hook = event [ "{" matcher *( "," matcher ) "}" ] ":" move
event    = name *( "." name )
name     = ALPHA *( ALPHA / DIGIT / "_" / "-" )
matcher  = key "=" value
key      = ALPHA *( ALPHA / DIGIT / "_" )
value    = 1*( unreserved / pct-encoded )
move     = "observe" / "rewrite" / "answer"
```

The grammar admits no whitespace. Event names, keys and values are case-sensitive and are compared as the host writes them. A declaration is in canonical form when:

1. its matchers are sorted by key in ascending code-point order, and no key appears twice;
2. every octet of a value outside `unreserved` is percent-encoded from its UTF-8 bytes, and nothing else is;
3. percent-encodings use uppercase hexadecimal digits.

An implementation that checks a mod MUST bring both the declared hooks and the host-derived hooks to canonical form before comparing them, and then compare the strings byte for byte. A declaration that does not match the grammar MUST fail the check. For example, a hook on `tool.call` matching the Bash tool and the working directory `/srv/app` is written `tool.call{cwd=%2Fsrv%2Fapp,tool=Bash}:answer`.

A mod carries these fields in the carriers its files already use: a root `mx` object in a JSON plugin manifest, and `@mx:` tags in the module's leading JSDoc block (§3.3).

```json
{
  "name": "blast-radius",
  "version": "0.1.0",
  "mx": {
    "modHooks": ["tool.call{tool=Bash}:answer", "ui.render{component=Pane}:observe"],
    "modCapabilities": ["process", "ui", "session"],
    "modGuarantee": "A safety net that reads the command text; not a permission system.",
    "testedWith": "claude-code@2.1.287"
  }
}
```

**Declared against derived (Normative).** Where the host can derive a mod's hooks and API calls from its source, an implementation that checks a mod MUST compare the derivation with `modHooks` and `modCapabilities`. A hook or capability found in the code but missing from the declaration MUST fail the check. A declared hook or capability the source no longer uses SHOULD be reported as stale. A mod whose hooks include a `rewrite` or `answer` move SHOULD contribute a step to the provenance record of any decision it shaped; a mod that only observes need not.

---

## 6. Vendor extensions

Carrier formats accept vendor extension fields under a three-level namespace policy:

- **Standard** (no prefix): the universal identity vocabulary plus the fields in this specification.
- **Vendor public** (`x-<vendor>-` prefix): vendor-specific carrier-format additions, openly published.
- **Vendor private** (`x-<vendor>-p-` prefix): vendor-specific additions, obfuscated or registry-decoded.

Implementations MUST NOT add a prefix to standard fields, and MUST NOT use `x-` prefixes for fields that already belong to the standard vocabulary.

The detailed namespace policy (governance, prefix-parsing rules, registration process) is specified in a separate note covering MX extensions.

---

## 7. Out of scope

This specification is scoped to carrier mechanisms and the small code-specific provenance vocabulary. The following concerns are explicitly out of scope:

- **Function-level annotations** (`pure`, `idempotent`, `complexity`, `throws`, `returns`, `param`) - defer to JSDoc, Python docstring convention, Doxygen, rustdoc, godoc.
- **API surface specification** (HTTP method, path, auth, rate limits, cache semantics) - defer to [OpenAPI](https://www.openapis.org/).
- **Test metadata** (test type, coverage targets, fixtures) - defer to test framework conventions.
- **Class-level annotations** (design pattern, thread-safety, invariants) - defer to language convention and code reviews.
- **Dependency vocabulary** (purpose, criticality, upgrade policy, alternatives considered) - defer to package manifests (`package.json`, `pyproject.toml`, `Cargo.toml`) and Architecture Decision Records.
- **Runtime configuration** (interpreter, language version, framework versions) - defer to native config (`.node-version`, `.tool-versions`, shebang lines, package manifests).
- **Coding conventions** (style, testing conventions, documentation conventions) - defer to linter configs and community style guides.
- **Inline code annotations** (`mx:begin`, `mx:end`, `mx:sensitive`, `mx:intentional`, `mx:todo`, `mx:ai`) - each language already has its own TODO-comment and annotation conventions.
- **Database content vocabulary** (table relationships, column types, dataset semantics) - defer to DCAT v3, CSVW, Dublin Core.
- **Image content vocabulary** (subject, alt text, EXIF camera fields) - defer to EXIF, IPTC, XMP, Schema.org.
- **Audio/video content vocabulary** (duration, bitrate, captions, chapters) - defer to ID3, XMP, Schema.org.
- **Document identity field semantics** (what `title`, `author`, `created`, `description` mean) - governed by the MX Core Metadata specification.
- **Cog file format internals** (the `.cog.md` body grammar, content blocks) - governed by the MX Cogs specification.

If an implementation needs any of these, it uses the relevant external convention or sibling note. This specification does not duplicate them.

---

## 8. Relationship to existing standards

MX is explicit about deferring to established vocabularies:

- **JSDoc / TSDoc / Python docstrings / Doxygen / rustdoc / godoc** - code-level documentation is each language's own convention.
- **OpenAPI** - full API surface specification.
- **Package manifests** (`package.json`, `pyproject.toml`, `Cargo.toml`, `go.mod`) - dependency declarations.
- **Dublin Core / Schema.org** - generic metadata (dates, rights, formats, display names).
- **Test framework conventions** - unit/integration/e2e classification, coverage targets, fixtures.
- **DCAT / CSVW** - dataset and tabular data metadata.
- **EXIF / IPTC / XMP / ID3** - embedded media metadata.
- **HTML `<meta>` standard** - base mechanism for `<meta name="mx:*">` carriers.
- **XMP namespace mechanism** - base mechanism for the `mx:` XMP namespace at `https://allabout.network/ns/mx/1.0`.

---

## 9. References

### 9.1 Normative references

- [RFC 2119](https://www.rfc-editor.org/rfc/rfc2119) - Key words for use in RFCs to indicate requirement levels
- [RFC 3986](https://www.rfc-editor.org/rfc/rfc3986) - Uniform Resource Identifier generic syntax (`unreserved` and `pct-encoded`, used by the §5.4 hook string)
- [RFC 5234](https://www.rfc-editor.org/rfc/rfc5234) - Augmented BNF for syntax specifications (the §5.4 hook-string grammar)

### 9.2 Informative references - external standards MX defers to

- [DCAT v3](https://www.w3.org/TR/vocab-dcat-3/) - datasets and data catalogues
- [CSVW](https://www.w3.org/TR/tabular-metadata/) - tabular data schemas
- [Dublin Core](https://www.dublincore.org/specifications/dublin-core/dcmi-terms/) - generic resource metadata
- [Schema.org](https://schema.org/) - web content vocabulary
- [EXIF](https://www.cipa.jp/std/documents/e/DC-008-Translation-2019-E.pdf) / [IPTC](https://iptc.org/standards/photo-metadata/) / [XMP](https://developer.adobe.com/xmp/docs/XMPSpecifications/) / [ID3](https://id3.org/) - embedded media metadata
- [OpenAPI](https://www.openapis.org/) - API surface specification
- [JSDoc](https://jsdoc.app/) / [Python Docstring (PEP 257)](https://peps.python.org/pep-0257/) / [Doxygen](https://www.doxygen.nl/) / [rustdoc](https://doc.rust-lang.org/rustdoc/) / [godoc](https://pkg.go.dev/cmd/doc) - code behaviour documentation
- [IETF RFC format](https://www.rfc-editor.org/rfc/rfc7322) - standards-document authoring
- [WCAG 2.1](https://www.w3.org/TR/WCAG21/) - Web Content Accessibility Guidelines (conformance level model)
- [Schema.org `codeRepository`](https://schema.org/codeRepository) - alignment for `sourceRepo`

---

*End of MX Carrier Formats specification draft.*
