Factory · Layer 2 · Data model
Agree on what the data means.
The data model names the concepts the whole system shares and the rules they obey, independent of any database or programming language. Every architecture, mock and product reads the same meaning.
What it holds
- Concepts with a definition and lifecycle.
- Attributes with meaning, type and cardinality.
- Relationships between concepts.
- Identity: which attributes make a record unique.
- Invariants: rules that must always hold.
- Links to the specification nodes each concept serves.
Why it exists
Most integration bugs are disagreements about meaning: what a booking is, when it ends, what makes two records the same. Settling that once, before choosing technology, lets every component and every architecture variant build on the same definitions.
A small example
Illustrative concept from a booking app. The model is logical: it says nothing about tables or classes.
{
"id": "appointment",
"definition": "A customer's claim on one slot.",
"lifecycle": "requested → confirmed → cancelled",
"spec_refs": ["book-appointment"],
"attributes": [
{ "id": "slot", "meaning": "The time and staff member booked", "type": "reference", "cardinality": "one" },
{ "id": "status", "meaning": "Where the booking is in its lifecycle", "type": "text", "cardinality": "one" }
],
"relationships": [
{ "id": "booked-by", "target": "customer", "meaning": "The customer who booked it" }
],
"invariants": [
{ "id": "one-booking-per-slot", "statement": "A slot has at most one confirmed appointment." }
]
}Changing a model
The first revision is saved whole. After that, your agent changes only what it needs (add an attribute, rename a concept, remove an invariant) and Factory checks the complete result before recording a new revision. A rename updates every reference inside the model, and architectures that still use the old name are told the new one.
How it is checked
- Shape: every concept, attribute, relationship and invariant is complete.
- Graph: ids are unique, relationship targets and identity attributes exist.
- Every specification reference exists in the exact spec revision the model pins.
- A change names the head revision it was based on; a newer head is refused, not overwritten.
- All errors come back at once with their location, and a dry run checks a change without saving it.
Tools
mfm_factory_schemareadsRead Command Schemas. Without arguments, a compact index: the envelope fields and every command type with its summary and required fields.mfm_factory_mutatewritesSubmit Factory Command. Submit one typed Factory command.mfm_factory_readreadsRead Factory Record. Read an exact Factory record, its version and recorded provenance.mfm_factory_graphreadsRead Design Graph. Read a bounded graph page at an exact design/run.
Your agent's step-by-step procedure for this layer is in references/formats.md of the mfm-factory skill. This page explains the concepts; the skill is the operating guide.