Skip to main contentA-REX Foundation

سجلات القرارات · ADR-017

ADR-017: Namespaced extensions in batch metadata (schema 1.3.0)

Hooks are the single extension point of A REX Core, and anyone can deploy one. A rule often needs facts about a batch that the core fields do not hold. Examples: a moisture reading at intake, the registry serials of carb

**Proposed** (2026-10-22). Not accepted: it needs the confirmation of two independent implementers ([GOVERNANCE.md](../GOVERNANCE.md))
معرّف المستند
ADR-017
التاريخ
2026-10-22
متوفر بالإنجليزية فقط
هذه الصفحة بالإنجليزية. فصول الورقة البيضاء والمخططات وصفحات المنصة مترجمة؛ وتتبع مقالات المساعدة لغات المساعدة في وحدة التحكم. يبقى المعيار المعياري في المستودع؛ استخدم طلب وصول مبكر لذلك النص. وتبقى أدلة تصميم النظام وسجلات القرارات بالإنجليزية.

Fields that a rule or add-on adds to a batch live in the metadata document under extensions.<key>, one object per rule, each validated by the JSON Schema fragment the rule publishes in its descriptor.

FieldValue
IDADR-017
Subject areaMetadata schema
StatusProposed (2026-10-22). Not accepted: it needs the confirmation of two independent implementers (GOVERNANCE.md)
Date2026-10-22
OwnersA-REX Contributors; requested by the A-REX Platform (HOOKS.md, owner decision Q7)
Related requirementsAREX-CORE §3.5 (metadata), §5 (hooks)
Supersedes / superseded by—

Context

Hooks are the single extension point of A-REX Core, and anyone can deploy one. A rule often needs facts about a batch that the core fields do not hold. Examples: a moisture reading at intake, the registry serials of carbon credits set aside for a lot, the cold-chain profile of a delivery. Today an issuer can add such fields anywhere, because the schema allows additional properties at the top level ("additionalProperties": true). Two rules can then pick the same name with different meanings. A validator cannot check the fields, and a reader cannot tell which rule they belong to.

Issue

Where do fields contributed by rules and add-ons go in the batch metadata document, and how are they validated?

Assumptions

  • Rules publish a descriptor (interop/RULE-DESCRIPTOR.md) with a stable key (^[a-z][a-z_]{2,40}$) and, optionally, a JSON Schema fragment lotFields.schema.
  • The metadata document is committed on chain by metadataHash, so fields can never be added to a batch afterwards, only to a new document (setBatchMetadata) or a new batch.

Constraints

  • Every document valid under 1.0.0, 1.1.0 and 1.2.0 stays valid (minor release).
  • No personal data in public documents (AREX-CORE §3.5, restricted).

Alternatives considered

AlternativeForAgainstOutcome
Keep free top-level fieldsnothing to changename collisions, no validation, no ownerRejected
attributes (ERC-1155 traits)existsuntyped display traits, no namespaceRejected
One object per rule under extensions, keyed by the rule's descriptor key, validated by the descriptor's fragmentno collisions, validation per rule, the reader knows whose field it isvalidators need the descriptors of the rules involvedProposed

Decision (proposed)

Schema 1.3.0 adds one optional top-level property:

"extensions": {
  "type": "object",
  "description": "Fields contributed by rules (hooks) and add-ons, one object per rule, keyed by the rule descriptor's `key` (interop/RULE-DESCRIPTOR.md). Each object is validated by the JSON Schema fragment of that rule's descriptor (`lotFields.schema`). Personal data never goes here; use `restricted`.",
  "propertyNames": { "pattern": "^[a-z][a-z_]{2,40}$" },
  "additionalProperties": { "type": "object" }
}

and schemaVersion accepts "1.3.0" besides "1.0.0", "1.1.0" and "1.2.0".

Rules:

  • A rule's fields MUST be placed under extensions.<key> of that rule.
  • A validator that has the descriptor of a rule SHOULD validate extensions.<key> with its lotFields.schema. Without the descriptor it accepts the object as opaque.
  • Top-level additional properties stay allowed for backward compatibility. New rules SHOULD NOT use them.
  • EPCIS mappings (interop/EPCIS.md) carry extensions.<key> as ILMD under a namespace derived from the rule's publisher id.

Argument

The rule's key already identifies it across versions, and its descriptor already carries the schema. Keying the fields by the same key makes every field traceable to the rule that asked for it. Validation is per rule, so one malformed rule never blocks the rest of the document.

Consequences

Positive

  • Rules from different publishers can add fields without colliding.
  • Forms and validators are generated from the descriptor.

Negative

  • A reader without the descriptor sees opaque objects.

Obligations it creates

  • A test in test/metadata-schema.test.mjs for extensions (valid object, invalid key, old documents still valid).
  • interop/EPCIS.md: an ILMD mapping for extensions.

Implementation and evidence

WhatWhere
Descriptor formatinterop/RULE-DESCRIPTOR.md, interop/rule-descriptor.schema.json
First consumerA-REX Platform, docs/HOOKS.md §5.3 (uses extensions today, valid under 1.2.0 because additional properties are allowed)
Schema changepending acceptance; not in schema/batch-metadata.schema.json yet
  • ADR-001: only the specification and the interfaces are normative (the descriptor is informative)
  • ADR-004: every rule is an independent IARexHook contract
  • ADR-008: no coordinates or natural-person identifiers in the batch record
  • ADR-014: carbon credits as records of immobilised registry credits (a first user of extensions)