# Metaprogramming / Language-Oriented Architecture

> Every principle in this category is listed as a record.

Page: Ontology · Principles
Canonical: https://banes-lab.com/ontology#architecture-category-metaprogramming-language-oriented-architecture

Listed in [Ontology · Principles](https://banes-lab.com/api/pages/ontology/principles.md), after [Metadata / Self-Description / Declarative Systems](https://banes-lab.com/ontology/principles/architecture-category-metadata-self-description-declarative-systems.md) and before [Model Architecture](https://banes-lab.com/ontology/principles/architecture-category-model-architecture.md).

Every principle in this category is listed as a record. Each record carries its kind, its severity, the scopes it applies at and the layer it lives in, then the edge relations that join it to other records, the records that point back at it, the contracts that answer to it and the tensions it takes part in. The descriptors say how it is violated, detected, measured, repaired and enforced. Where the record carries one, an exemplar shows the shape before and after the principle is applied.

Relations diagram

The relations inside this category.

```mermaid
flowchart LR
n_homoiconicity["Homoiconicity"]
n_code_as_data["Code as Data"]
n_metaprogramming["Metaprogramming"]
n_reflection["Reflection"]
n_introspection["Introspection"]
n_compile_time_evaluation["Compile-Time Evaluation"]
n_runtime_code_generation["Runtime Code Generation"]
n_domain_specific_language["Domain-Specific Language (DSL)"]
n_language_oriented_programming["Language-Oriented Programming"]
n_model_driven_architecture["Model-Driven Architecture"]
n_homoiconicity --> n_metaprogramming
n_code_as_data --> n_homoiconicity
n_reflection --> n_introspection
```

### Homoiconicity

- Kind: [quality-attribute](https://banes-lab.com/records/kind/quality-attribute.md)
- Category: [Metaprogramming / Language-Oriented Architecture](https://banes-lab.com/ontology/principles/architecture-category-metaprogramming-language-oriented-architecture.md)
- Severity: [contextual](https://banes-lab.com/records/vocabulary/severity-contextual.md)
- Scope: language, metaprogramming
- Layer: [Declarative Core](https://banes-lab.com/records/layer/declarative-core.md)

Details

Definition
The degree to which a language represents its programs in its own data structures, so programs can be inspected and transformed as data.

Requires
[Code-as-Data Representation](https://banes-lab.com/records/lexicon/code-as-data-representation.md)

Reinforces
[Metaprogramming](https://banes-lab.com/records/architecture/metaprogramming.md)

Enables
[Macro Systems](https://banes-lab.com/records/lexicon/macro-systems.md), [DSLs](https://banes-lab.com/records/lexicon/dsls.md)

In tension with
[Readability](https://banes-lab.com/records/lexicon/readability.md)

Conflicts with
[Opaque Syntax Trees](https://banes-lab.com/records/lexicon/opaque-syntax-trees.md)

Referenced by
[Code as Data](https://banes-lab.com/records/architecture/code-as-data.md)

Tensions
[Homoiconicity / Readability](https://banes-lab.com/records/tension/homoiconicity-readability.md)

Distinct from
[Readability](https://banes-lab.com/records/lexicon/readability.md): Homoiconicity is programs held as data, while readability is how easily the developer reads the source that results.

Violated by
code transformed as strings where the language offers a code-as-data form

Detected by
language capability check

Measured by
macro/code-as-data usage

Refactored by
Use AST/DSL/Macro Representation

Enforced by
language/tooling constraints

Refused by rules
homoiconicity

Before

```typescript
function evaluateFoo(foo: Foo) { return foo.value * 2; }
const fooRule = { operation: "multiply", operand: 2 };
```

After

```typescript
type Expr =
| { op: "value"; key: keyof Foo }
| { op: "const"; value: number }
| { op: "multiply"; left: Expr; right: Expr };
const fooRule: Expr = { op: "multiply", left: { op: "value", key: "value" }, right: { op: "const", value: 2 } };
const result = evaluate(fooRule, foo);
```

How it is checked

Checked by
language/tooling constraints

Population
Every generator, reflective access, evaluation site and language definition in the codebase

Freshness
A verdict stands until a generator, a grammar or the model it generates from changes

Refusal
The banned-API rule, the generator test or the grammar validation fails the change

Observation
Eval and reflection call sites read from source, and generated output compared with its model

Evidence
None, because the catalog states this check as a class, so a watched run belongs to each system that adopts it

Authoritative side
The model and the grammar, which generated output is derived from and compared against

Depends on
[Code-as-Data Representation](https://banes-lab.com/records/lexicon/code-as-data-representation.md), [Metaprogramming](https://banes-lab.com/records/architecture/metaprogramming.md), [Macro Systems](https://banes-lab.com/records/lexicon/macro-systems.md), [DSLs](https://banes-lab.com/records/lexicon/dsls.md)

Shape it refuses
[Opaque Syntax Trees](https://banes-lab.com/records/lexicon/opaque-syntax-trees.md)

### Code as Data

- Kind: [principle](https://banes-lab.com/records/kind/principle.md)
- Category: [Metaprogramming / Language-Oriented Architecture](https://banes-lab.com/ontology/principles/architecture-category-metaprogramming-language-oriented-architecture.md)
- Severity: [contextual](https://banes-lab.com/records/vocabulary/severity-contextual.md)
- Scope: language, compiler, runtime
- Layer: [Declarative Core](https://banes-lab.com/records/layer/declarative-core.md)

Details

Definition
A design rule that logic to be generated or transformed is held as a typed data structure, such as a syntax tree, that tools can inspect and rewrite.

Requires
[AST or Data Representation](https://banes-lab.com/records/lexicon/ast-or-data-representation.md)

Reinforces
[Homoiconicity](https://banes-lab.com/records/architecture/homoiconicity.md), [Code Generation](https://banes-lab.com/records/lexicon/code-generation.md)

Enables
[Program Transformation](https://banes-lab.com/records/lexicon/program-transformation.md)

In tension with
[Safety/Debuggability](https://banes-lab.com/records/lexicon/safety-debuggability.md)

Conflicts with
[String-Based Code Generation](https://banes-lab.com/records/lexicon/string-based-code-generation.md)

Tensions
[Code as Data / Safety/Debuggability](https://banes-lab.com/records/tension/code-as-data-safety-debuggability.md)

Violated by
unsafe string eval/generation

Detected by
dynamic eval/string code construction

Measured by
unsafe eval count

Refactored by
Use AST Builder, Typed DSL

Enforced by
banned API rules

Before

```typescript
function fooRule(foo: Foo) { return foo.count > 3 && foo.active; }
```

After

```typescript
const fooRule = {
op: "and",
args: [
{ op: "gt", field: "count", value: 3 },
{ op: "eq", field: "active", value: true },
],
} as const;
executeRule(fooRule, foo);
```

How it is checked

Checked by
banned API rules

Population
Every generator, reflective access, evaluation site and language definition in the codebase

Freshness
A verdict stands until a generator, a grammar or the model it generates from changes

Refusal
The banned-API rule, the generator test or the grammar validation fails the change

Observation
Eval and reflection call sites read from source, and generated output compared with its model

Evidence
None, because the catalog states this check as a class, so a watched run belongs to each system that adopts it

Authoritative side
The model and the grammar, which generated output is derived from and compared against

Depends on
[AST or Data Representation](https://banes-lab.com/records/lexicon/ast-or-data-representation.md), [Homoiconicity](https://banes-lab.com/records/architecture/homoiconicity.md), [Code Generation](https://banes-lab.com/records/lexicon/code-generation.md), [Program Transformation](https://banes-lab.com/records/lexicon/program-transformation.md)

Shape it refuses
[String-Based Code Generation](https://banes-lab.com/records/lexicon/string-based-code-generation.md)

### Metaprogramming

- Kind: [technique](https://banes-lab.com/records/kind/technique.md)
- Category: [Metaprogramming / Language-Oriented Architecture](https://banes-lab.com/ontology/principles/architecture-category-metaprogramming-language-oriented-architecture.md)
- Severity: [contextual](https://banes-lab.com/records/vocabulary/severity-contextual.md)
- Scope: compile-time, runtime, framework
- Layer: [Declarative Core](https://banes-lab.com/records/layer/declarative-core.md)

Details

Definition
A technique for writing programs that generate or transform other programs, at compile time or at runtime.

Requires
[Reflection/AST/Code Generation](https://banes-lab.com/records/lexicon/reflection-ast-code-generation.md)

Reinforces
[Do Not Repeat Yourself (DRY)](https://banes-lab.com/records/architecture/duplicate-code.md), [DSLs](https://banes-lab.com/records/lexicon/dsls.md)

Enables
[Boilerplate Elimination](https://banes-lab.com/records/lexicon/boilerplate-elimination.md)

In tension with
[Debuggability](https://banes-lab.com/records/lexicon/debuggability.md), [Static Analysis](https://banes-lab.com/records/architecture/static-analysis.md), [Explicit Handwritten Code](https://banes-lab.com/records/lexicon/explicit-handwritten-code.md)

Conflicts with
none

Referenced by
[Homoiconicity](https://banes-lab.com/records/architecture/homoiconicity.md)

Tensions
[Metaprogramming / Debuggability](https://banes-lab.com/records/tension/debuggability-metaprogramming.md), [Metaprogramming / Static Analysis](https://banes-lab.com/records/tension/metaprogramming-static-analysis.md), [Metaprogramming / Explicit Handwritten Code](https://banes-lab.com/records/tension/explicit-handwritten-code-metaprogramming.md)

Distinct from
[DSLs](https://banes-lab.com/records/lexicon/dsls.md): Metaprogramming is code that writes or transforms code, while a domain-specific language is a notation for one domain, which metaprogramming can build.

Violated by
unsafe/opaque generated behavior

Detected by
dynamic generation without tests/schema

Measured by
generated code coverage, [complexity](https://banes-lab.com/records/reasoning/lens-complexity.md)

Refactored by
Add Generator Tests, Make Metadata Explicit

Enforced by
generator validation

Before

```typescript
class FooDto { id!: string; name!: string; }
class BarDto { id!: string; name!: string; }
```

After

```typescript
const entity = defineEntity({ id: string(), name: string() });
const FooDto = generateType("FooDto", entity);
const BarDto = generateType("BarDto", entity);
```

How it is checked

Checked by
generator validation

Population
Every generator, reflective access, evaluation site and language definition in the codebase

Freshness
A verdict stands until a generator, a grammar or the model it generates from changes

Refusal
The banned-API rule, the generator test or the grammar validation fails the change

Observation
Eval and reflection call sites read from source, and generated output compared with its model

Evidence
None, because the catalog states this check as a class, so a watched run belongs to each system that adopts it

Authoritative side
The model and the grammar, which generated output is derived from and compared against

Depends on
[Reflection/AST/Code Generation](https://banes-lab.com/records/lexicon/reflection-ast-code-generation.md), [Do Not Repeat Yourself (DRY)](https://banes-lab.com/records/architecture/duplicate-code.md), [DSLs](https://banes-lab.com/records/lexicon/dsls.md), [Boilerplate Elimination](https://banes-lab.com/records/lexicon/boilerplate-elimination.md)

Shape it refuses
Not answered

### Reflection

- Kind: [mechanism](https://banes-lab.com/records/kind/mechanism.md)
- Category: [Metaprogramming / Language-Oriented Architecture](https://banes-lab.com/ontology/principles/architecture-category-metaprogramming-language-oriented-architecture.md)
- Severity: [contextual](https://banes-lab.com/records/vocabulary/severity-contextual.md)
- Scope: runtime, metadata, framework
- Layer: [Declarative Core](https://banes-lab.com/records/layer/declarative-core.md)

Details

Definition
A mechanism that lets a program read and act on type metadata about its own structure at runtime.

Requires
[Runtime Type Metadata](https://banes-lab.com/records/lexicon/runtime-type-metadata.md)

Reinforces
[Introspection](https://banes-lab.com/records/architecture/introspection.md), [Runtime Discovery](https://banes-lab.com/records/architecture/runtime-discovery.md)

Enables
[Dynamic Binding](https://banes-lab.com/records/architecture/dynamic-binding.md)

In tension with
[Performance/Safety](https://banes-lab.com/records/lexicon/performance-safety.md), [Static Analysis](https://banes-lab.com/records/architecture/static-analysis.md)

Conflicts with
none

Tensions
[Reflection / Performance/Safety](https://banes-lab.com/records/tension/performance-safety-reflection.md), [Reflection / Static Analysis](https://banes-lab.com/records/tension/reflection-static-analysis.md)

Distinct from
[Dynamic Binding](https://banes-lab.com/records/architecture/dynamic-binding.md): Reflection reads type metadata at runtime, while dynamic binding selects an implementation at runtime, with or without reflection.

Distinct from
[Introspection](https://banes-lab.com/records/architecture/introspection.md): Introspection only reads a type and its members, while reflection also acts on what it reads.

Distinct from
[Static Analysis](https://banes-lab.com/records/architecture/static-analysis.md): Reflection inspects structure while the program runs, while static analysis inspects source without running it.

Violated by
reflection used to bypass contracts/visibility

Detected by
reflective access to internals

Measured by
unsafe reflection count

Refactored by
Replace with Explicit Interface/Metadata

Enforced by
lint/security rules

Before

```typescript
const fields = ["id", "name", "count"];
for (const field of fields) renderField(foo[field]);
```

After

```typescript
for (const [field, metadata] of reflect(FooSchema).entries()) {
renderField(field, metadata, foo[field]);
}
```

How it is checked

Checked by
lint/security rules

Population
Every generator, reflective access, evaluation site and language definition in the codebase

Freshness
A verdict stands until a generator, a grammar or the model it generates from changes

Refusal
The banned-API rule, the generator test or the grammar validation fails the change

Observation
Eval and reflection call sites read from source, and generated output compared with its model

Evidence
None, because the catalog states this check as a class, so a watched run belongs to each system that adopts it

Authoritative side
The model and the grammar, which generated output is derived from and compared against

Depends on
[Runtime Type Metadata](https://banes-lab.com/records/lexicon/runtime-type-metadata.md), [Introspection](https://banes-lab.com/records/architecture/introspection.md), [Runtime Discovery](https://banes-lab.com/records/architecture/runtime-discovery.md), [Dynamic Binding](https://banes-lab.com/records/architecture/dynamic-binding.md)

Shape it refuses
Not answered

### Introspection

- Kind: [mechanism](https://banes-lab.com/records/kind/mechanism.md)
- Category: [Metaprogramming / Language-Oriented Architecture](https://banes-lab.com/ontology/principles/architecture-category-metaprogramming-language-oriented-architecture.md)
- Severity: [contextual](https://banes-lab.com/records/vocabulary/severity-contextual.md)
- Scope: runtime, metadata
- Layer: [Declarative Core](https://banes-lab.com/records/layer/declarative-core.md)

Details

Definition
A mechanism that lets a program query an object's type and public members at runtime without changing them.

Requires
[Type Metadata](https://banes-lab.com/records/lexicon/type-metadata.md)

Reinforces
[Self-Describing Systems](https://banes-lab.com/records/lexicon/self-describing-systems.md)

Enables
[Discovery](https://banes-lab.com/records/lexicon/discovery.md), [Diagnostics](https://banes-lab.com/records/lexicon/diagnostics.md)

In tension with
[Encapsulation](https://banes-lab.com/records/architecture/encapsulation.md)

Conflicts with
[Opaque Runtime Behavior](https://banes-lab.com/records/architecture/opaque-runtime-behavior.md)

Referenced by
[Self-Describing Structures](https://banes-lab.com/records/architecture/self-describing-structures.md), [Reflection](https://banes-lab.com/records/architecture/reflection.md)

Tensions
[Introspection / Encapsulation](https://banes-lab.com/records/tension/encapsulation-introspection.md)

Violated by
relying on undocumented internal structure

Detected by
introspection of private internals

Measured by
introspection usage risk

Refactored by
Add Public Metadata API

Enforced by
API boundaries

Before

```typescript
function supportsExport(plugin: any) {
try { plugin.exportFoo(foo); return true; } catch { return false; }
}
```

After

```typescript
function supportsExport(plugin: Plugin) {
return introspect(plugin).methods.includes("exportFoo");
}
```

How it is checked

Checked by
API boundaries

Population
Every generator, reflective access, evaluation site and language definition in the codebase

Freshness
A verdict stands until a generator, a grammar or the model it generates from changes

Refusal
The banned-API rule, the generator test or the grammar validation fails the change

Observation
Eval and reflection call sites read from source, and generated output compared with its model

Evidence
None, because the catalog states this check as a class, so a watched run belongs to each system that adopts it

Authoritative side
The model and the grammar, which generated output is derived from and compared against

Depends on
[Type Metadata](https://banes-lab.com/records/lexicon/type-metadata.md), [Self-Describing Systems](https://banes-lab.com/records/lexicon/self-describing-systems.md), [Discovery](https://banes-lab.com/records/lexicon/discovery.md), [Diagnostics](https://banes-lab.com/records/lexicon/diagnostics.md)

Shape it refuses
[Opaque Runtime Behavior](https://banes-lab.com/records/architecture/opaque-runtime-behavior.md), [Opaque Runtime Behavior](https://banes-lab.com/records/architecture/opaque-runtime-behavior.md)

### Compile-Time Evaluation

- Kind: [mechanism](https://banes-lab.com/records/kind/mechanism.md)
- Category: [Metaprogramming / Language-Oriented Architecture](https://banes-lab.com/ontology/principles/architecture-category-metaprogramming-language-oriented-architecture.md)
- Severity: [contextual](https://banes-lab.com/records/vocabulary/severity-contextual.md)
- Scope: compiler, build
- Layer: [Declarative Core](https://banes-lab.com/records/layer/declarative-core.md)

Details

Definition
A mechanism that computes values, checks or generated code during the build, so the work and its errors happen before runtime.

Requires
[Compile-Time Inputs](https://banes-lab.com/records/lexicon/compile-time-inputs.md)

Reinforces
[Optimization](https://banes-lab.com/records/architecture/optimization.md), [Type Safety](https://banes-lab.com/records/architecture/type-safety.md)

Enables
[Early Error Detection](https://banes-lab.com/records/lexicon/early-error-detection.md)

In tension with
[Build Complexity](https://banes-lab.com/records/lexicon/build-complexity.md), [Runtime Dynamic Evaluation](https://banes-lab.com/records/lexicon/runtime-dynamic-evaluation.md)

Conflicts with
none

Tensions
[Compile-Time Evaluation / Build Complexity](https://banes-lab.com/records/tension/build-complexity-compile-time-evaluation.md), [Compile-Time Evaluation / Runtime Dynamic Evaluation](https://banes-lab.com/records/tension/compile-time-evaluation-runtime-dynamic-evaluation.md)

Violated by
runtime work that could be validated/generated at compile time

Detected by
repeated runtime reflection/validation

Measured by
compile-time coverage

Refactored by
Move Check/Generation to Compile Time

Enforced by
compiler plugins/build checks

Before

```typescript
const fooRoutes = buildRoutesAtStartup(fooRouteDefinitions);
```

After

```typescript
const fooRoutes = compileTime(() => buildRoutes(fooRouteDefinitions));
export const routeTable = fooRoutes;
```

How it is checked

Checked by
compiler plugins/build checks

Population
Every generator, reflective access, evaluation site and language definition in the codebase

Freshness
A verdict stands until a generator, a grammar or the model it generates from changes

Refusal
The banned-API rule, the generator test or the grammar validation fails the change

Observation
Eval and reflection call sites read from source, and generated output compared with its model

Evidence
None, because the catalog states this check as a class, so a watched run belongs to each system that adopts it

Authoritative side
The model and the grammar, which generated output is derived from and compared against

Depends on
[Compile-Time Inputs](https://banes-lab.com/records/lexicon/compile-time-inputs.md), [Optimization](https://banes-lab.com/records/architecture/optimization.md), [Type Safety](https://banes-lab.com/records/architecture/type-safety.md), [Early Error Detection](https://banes-lab.com/records/lexicon/early-error-detection.md)

Shape it refuses
Not answered

### Runtime Code Generation

- Kind: [mechanism](https://banes-lab.com/records/kind/mechanism.md)
- Category: [Metaprogramming / Language-Oriented Architecture](https://banes-lab.com/ontology/principles/architecture-category-metaprogramming-language-oriented-architecture.md)
- Severity: [discouraged](https://banes-lab.com/records/vocabulary/severity-discouraged.md)
- Scope: runtime, framework
- Layer: [Declarative Core](https://banes-lab.com/records/layer/declarative-core.md)

Details

Definition
A mechanism that builds executable code while the program runs, from a specification such as a field mapping.

Requires
[Safe Generation Boundary](https://banes-lab.com/records/lexicon/safe-generation-boundary.md)

Reinforces
[Runtime Extensibility](https://banes-lab.com/records/architecture/runtime-extensibility.md)

Enables
[Dynamic Optimization/Adaptation](https://banes-lab.com/records/lexicon/dynamic-optimization-adaptation.md)

In tension with
[Security/Debugging](https://banes-lab.com/records/lexicon/security-debugging.md), [Static Safety](https://banes-lab.com/records/lexicon/static-safety.md)

Conflicts with
none

Tensions
[Runtime Code Generation / Security/Debugging](https://banes-lab.com/records/tension/runtime-code-generation-security-debugging.md), [Runtime Code Generation / Static Safety](https://banes-lab.com/records/tension/runtime-code-generation-static-safety.md)

Violated by
unsafe eval, untrusted code generation

Detected by
dynamic eval with external input

Measured by
unsafe generation paths

Refactored by
Use Safe Generator, Sandbox, Precompile

Enforced by
[security policy](https://banes-lab.com/records/algorithms/security-policy.md)

Before

```typescript
function mapFoo(row: any) {
return { id: row["foo_id"], name: row["foo_name"], count: row["foo_count"] };
}
```

After

```typescript
const mapFoo = generateMapper<FooRow, Foo>({
foo_id: "id",
foo_name: "name",
foo_count: "count",
});
```

How it is checked

Checked by
security policy

Population
Every generator, reflective access, evaluation site and language definition in the codebase

Freshness
A verdict stands until a generator, a grammar or the model it generates from changes

Refusal
The banned-API rule, the generator test or the grammar validation fails the change

Observation
Eval and reflection call sites read from source, and generated output compared with its model

Evidence
None, because the catalog states this check as a class, so a watched run belongs to each system that adopts it

Authoritative side
The model and the grammar, which generated output is derived from and compared against

Depends on
[Safe Generation Boundary](https://banes-lab.com/records/lexicon/safe-generation-boundary.md), [Runtime Extensibility](https://banes-lab.com/records/architecture/runtime-extensibility.md), [Dynamic Optimization/Adaptation](https://banes-lab.com/records/lexicon/dynamic-optimization-adaptation.md)

Shape it refuses
Not answered

### Domain-Specific Language (DSL)

- Kind: [pattern](https://banes-lab.com/records/kind/pattern.md)
- Category: [Metaprogramming / Language-Oriented Architecture](https://banes-lab.com/ontology/principles/architecture-category-metaprogramming-language-oriented-architecture.md)
- Severity: [contextual](https://banes-lab.com/records/vocabulary/severity-contextual.md)
- Scope: domain, configuration, rules
- Layer: [Declarative Core](https://banes-lab.com/records/layer/declarative-core.md)

Details

Definition
A design pattern that expresses a domain's rules or workflows in a small language with a defined grammar and a validator.

Requires
[Formal Grammar/Semantics](https://banes-lab.com/records/lexicon/formal-grammar-semantics.md)

Reinforces
[Declarative Configuration](https://banes-lab.com/records/architecture/declarative-configuration.md), [Ubiquitous Language](https://banes-lab.com/records/architecture/ubiquitous-language.md)

Enables
[Domain Expressiveness](https://banes-lab.com/records/lexicon/domain-expressiveness.md)

In tension with
[Tooling/Maintenance](https://banes-lab.com/records/lexicon/tooling-maintenance.md)

Conflicts with
[General-Purpose Boilerplate](https://banes-lab.com/records/lexicon/general-purpose-boilerplate.md)

Tensions
[Domain-Specific Language (DSL) / Tooling/Maintenance](https://banes-lab.com/records/tension/domain-specific-language-dsl-tooling-maintenance.md)

Violated by
ambiguous ad-hoc mini-language

Detected by
stringly-typed rules without parser/schema

Measured by
DSL validation coverage

Refactored by
Define Grammar, Add Parser/Validator

Enforced by
DSL tests, schema/grammar checks

Before

```typescript
createWorkflow([
{ type: "validate", target: "foo" },
{ type: "save", target: "foo" },
{ type: "publish", target: "foo.created" },
]);
```

After

```typescript
fooWorkflow("create", flow =>
flow.validate(FooSchema)
.save("FooStore")
.publish("FooCreated")
);
```

How it is checked

Checked by
DSL tests, schema/grammar checks

Population
Every generator, reflective access, evaluation site and language definition in the codebase

Freshness
A verdict stands until a generator, a grammar or the model it generates from changes

Refusal
The banned-API rule, the generator test or the grammar validation fails the change

Observation
Eval and reflection call sites read from source, and generated output compared with its model

Evidence
None, because the catalog states this check as a class, so a watched run belongs to each system that adopts it

Authoritative side
The model and the grammar, which generated output is derived from and compared against

Depends on
[Formal Grammar/Semantics](https://banes-lab.com/records/lexicon/formal-grammar-semantics.md), [Declarative Configuration](https://banes-lab.com/records/architecture/declarative-configuration.md), [Ubiquitous Language](https://banes-lab.com/records/architecture/ubiquitous-language.md), [Domain Expressiveness](https://banes-lab.com/records/lexicon/domain-expressiveness.md)

Shape it refuses
[General-Purpose Boilerplate](https://banes-lab.com/records/lexicon/general-purpose-boilerplate.md)

### Language-Oriented Programming

- Kind: [approach](https://banes-lab.com/records/kind/approach.md)
- Category: [Metaprogramming / Language-Oriented Architecture](https://banes-lab.com/ontology/principles/architecture-category-metaprogramming-language-oriented-architecture.md)
- Severity: [contextual](https://banes-lab.com/records/vocabulary/severity-contextual.md)
- Scope: domain, platform, code generation
- Layer: [Declarative Core](https://banes-lab.com/records/layer/declarative-core.md)

Details

Definition
An approach in which each problem domain gets its own language, with a type checker and an evaluator, and solutions are written in it.

Requires
[DSLs](https://banes-lab.com/records/lexicon/dsls.md), [Code Generation or Interpreters](https://banes-lab.com/records/lexicon/code-generation-or-interpreters.md)

Reinforces
[Domain Modeling](https://banes-lab.com/records/lexicon/domain-modeling.md)

Enables
[High-Level Domain Expression](https://banes-lab.com/records/lexicon/high-level-domain-expression.md)

In tension with
[Toolchain Complexity](https://banes-lab.com/records/lexicon/toolchain-complexity.md), [One-Size General-Purpose Code](https://banes-lab.com/records/lexicon/one-size-general-purpose-code.md)

Conflicts with
none

Tensions
[Language-Oriented Programming / Toolchain Complexity](https://banes-lab.com/records/tension/language-oriented-programming-toolchain-complexity.md), [Language-Oriented Programming / One-Size General-Purpose Code](https://banes-lab.com/records/tension/language-oriented-programming-one-size-general-purpose-code.md)

Distinct from
[One-Size General-Purpose Code](https://banes-lab.com/records/lexicon/one-size-general-purpose-code.md): Language-oriented programming gives each domain its own language, while general-purpose code writes every domain in one language.

Violated by
proliferation of informal unvalidated DSLs

Detected by
multiple inconsistent rule/config syntaxes

Measured by
language consistency/tooling

Refactored by
Consolidate DSL, Add Tooling

Enforced by
grammar/schema validation

Before

```typescript
function processFoo(config: Record<string, unknown>) {
interpretAdHocConfig(config);
}
```

After

```typescript
const FooPolicyLanguage = defineLanguage({
expressions: ["field", "equals", "all", "any"],
typeChecker: fooPolicyTypeChecker,
evaluator: fooPolicyEvaluator,
});
FooPolicyLanguage.run(fooPolicy, foo);
```

How it is checked

Checked by
grammar/schema validation

Population
Every generator, reflective access, evaluation site and language definition in the codebase

Freshness
A verdict stands until a generator, a grammar or the model it generates from changes

Refusal
The banned-API rule, the generator test or the grammar validation fails the change

Observation
Eval and reflection call sites read from source, and generated output compared with its model

Evidence
None, because the catalog states this check as a class, so a watched run belongs to each system that adopts it

Authoritative side
The model and the grammar, which generated output is derived from and compared against

Depends on
[DSLs](https://banes-lab.com/records/lexicon/dsls.md), [Code Generation or Interpreters](https://banes-lab.com/records/lexicon/code-generation-or-interpreters.md), [Domain Modeling](https://banes-lab.com/records/lexicon/domain-modeling.md), [High-Level Domain Expression](https://banes-lab.com/records/lexicon/high-level-domain-expression.md)

Shape it refuses
Not answered

### Model-Driven Architecture

- Kind: [approach](https://banes-lab.com/records/kind/approach.md)
- Category: [Metaprogramming / Language-Oriented Architecture](https://banes-lab.com/ontology/principles/architecture-category-metaprogramming-language-oriented-architecture.md)
- Severity: [contextual](https://banes-lab.com/records/vocabulary/severity-contextual.md)
- Scope: system, code generation, domain model
- Layer: [Declarative Core](https://banes-lab.com/records/layer/declarative-core.md)

Details

Definition
An approach in which a formal model is the source of truth and the implementation is generated from it by transformation rules.

Requires
[Formal Model](https://banes-lab.com/records/lexicon/formal-model.md), [Transformation Rules](https://banes-lab.com/records/lexicon/transformation-rules.md)

Reinforces
[Metadata-Driven Design](https://banes-lab.com/records/architecture/metadata-driven-design.md)

Enables
[Generated Implementations](https://banes-lab.com/records/lexicon/generated-implementations.md)

In tension with
none

Conflicts with
[Handwritten Divergence](https://banes-lab.com/records/lexicon/handwritten-divergence.md)

Distinct from
[Metadata-Driven Design](https://banes-lab.com/records/architecture/metadata-driven-design.md): Model-driven architecture generates the implementation from a formal model by transformation rules, while metadata-driven design drives forms, routes or plugins from validated metadata.

Violated by
generated code manually edited/diverged

Detected by
model-code drift

Measured by
generation conformance

Refactored by
Regenerate, Lock Generated Files, Update Model

Enforced by
generation CI

Before

```typescript
class FooController {}
class FooService {}
class FooRepository {}
class FooDto {}
```

After

```typescript
const fooModel = defineModel({
entity: "Foo",
fields: { id: "FooId", name: "string" },
operations: ["create", "read", "rename"],
});
generateApplication(fooModel);
```

How it is checked

Checked by
generation CI

Population
Every generator, reflective access, evaluation site and language definition in the codebase

Freshness
A verdict stands until a generator, a grammar or the model it generates from changes

Refusal
The banned-API rule, the generator test or the grammar validation fails the change

Observation
Eval and reflection call sites read from source, and generated output compared with its model

Evidence
None, because the catalog states this check as a class, so a watched run belongs to each system that adopts it

Authoritative side
The model and the grammar, which generated output is derived from and compared against

Depends on
[Formal Model](https://banes-lab.com/records/lexicon/formal-model.md), [Transformation Rules](https://banes-lab.com/records/lexicon/transformation-rules.md), [Metadata-Driven Design](https://banes-lab.com/records/architecture/metadata-driven-design.md), [Generated Implementations](https://banes-lab.com/records/lexicon/generated-implementations.md)

Shape it refuses
[Handwritten Divergence](https://banes-lab.com/records/lexicon/handwritten-divergence.md)

## Links to

- [quality-attribute](https://banes-lab.com/records/kind/quality-attribute.md)
- [contextual](https://banes-lab.com/records/vocabulary/severity-contextual.md)
- [Declarative Core](https://banes-lab.com/records/layer/declarative-core.md)
- [Code-as-Data Representation](https://banes-lab.com/records/lexicon/code-as-data-representation.md)
- [Metaprogramming](https://banes-lab.com/records/architecture/metaprogramming.md)
- [Macro Systems](https://banes-lab.com/records/lexicon/macro-systems.md)
- [DSLs](https://banes-lab.com/records/lexicon/dsls.md)
- [Readability](https://banes-lab.com/records/lexicon/readability.md)
- [Opaque Syntax Trees](https://banes-lab.com/records/lexicon/opaque-syntax-trees.md)
- [Code as Data](https://banes-lab.com/records/architecture/code-as-data.md)
- [Homoiconicity / Readability](https://banes-lab.com/records/tension/homoiconicity-readability.md)
- [principle](https://banes-lab.com/records/kind/principle.md)
- [AST or Data Representation](https://banes-lab.com/records/lexicon/ast-or-data-representation.md)
- [Homoiconicity](https://banes-lab.com/records/architecture/homoiconicity.md)
- [Code Generation](https://banes-lab.com/records/lexicon/code-generation.md)
- [Program Transformation](https://banes-lab.com/records/lexicon/program-transformation.md)
- [Safety/Debuggability](https://banes-lab.com/records/lexicon/safety-debuggability.md)
- [String-Based Code Generation](https://banes-lab.com/records/lexicon/string-based-code-generation.md)
- [Code as Data / Safety/Debuggability](https://banes-lab.com/records/tension/code-as-data-safety-debuggability.md)
- [technique](https://banes-lab.com/records/kind/technique.md)
- [Reflection/AST/Code Generation](https://banes-lab.com/records/lexicon/reflection-ast-code-generation.md)
- [Do Not Repeat Yourself](https://banes-lab.com/records/architecture/duplicate-code.md)
- [Boilerplate Elimination](https://banes-lab.com/records/lexicon/boilerplate-elimination.md)
- [Debuggability](https://banes-lab.com/records/lexicon/debuggability.md)
- [Static Analysis](https://banes-lab.com/records/architecture/static-analysis.md)
- [Explicit Handwritten Code](https://banes-lab.com/records/lexicon/explicit-handwritten-code.md)
- [Metaprogramming / Debuggability](https://banes-lab.com/records/tension/debuggability-metaprogramming.md)
- [Metaprogramming / Static Analysis](https://banes-lab.com/records/tension/metaprogramming-static-analysis.md)
- [Metaprogramming / Explicit Handwritten Code](https://banes-lab.com/records/tension/explicit-handwritten-code-metaprogramming.md)
- [Complexity](https://banes-lab.com/records/reasoning/lens-complexity.md)
- [mechanism](https://banes-lab.com/records/kind/mechanism.md)
- [Runtime Type Metadata](https://banes-lab.com/records/lexicon/runtime-type-metadata.md)
- [Introspection](https://banes-lab.com/records/architecture/introspection.md)
- [Runtime Discovery](https://banes-lab.com/records/architecture/runtime-discovery.md)
- [Dynamic Binding](https://banes-lab.com/records/architecture/dynamic-binding.md)
- [Performance/Safety](https://banes-lab.com/records/lexicon/performance-safety.md)
- [Reflection / Performance/Safety](https://banes-lab.com/records/tension/performance-safety-reflection.md)
- [Reflection / Static Analysis](https://banes-lab.com/records/tension/reflection-static-analysis.md)
- [Type Metadata](https://banes-lab.com/records/lexicon/type-metadata.md)
- [Self-Describing Systems](https://banes-lab.com/records/lexicon/self-describing-systems.md)
- [Discovery](https://banes-lab.com/records/lexicon/discovery.md)
- [Diagnostics](https://banes-lab.com/records/lexicon/diagnostics.md)
- [Encapsulation](https://banes-lab.com/records/architecture/encapsulation.md)
- [Opaque Runtime Behavior](https://banes-lab.com/records/architecture/opaque-runtime-behavior.md)
- [Self-Describing Structures](https://banes-lab.com/records/architecture/self-describing-structures.md)
- [Reflection](https://banes-lab.com/records/architecture/reflection.md)
- [Introspection / Encapsulation](https://banes-lab.com/records/tension/encapsulation-introspection.md)
- [Compile-Time Inputs](https://banes-lab.com/records/lexicon/compile-time-inputs.md)
- [Optimization](https://banes-lab.com/records/architecture/optimization.md)
- [Type Safety](https://banes-lab.com/records/architecture/type-safety.md)
- [Early Error Detection](https://banes-lab.com/records/lexicon/early-error-detection.md)
- [Build Complexity](https://banes-lab.com/records/lexicon/build-complexity.md)
- [Runtime Dynamic Evaluation](https://banes-lab.com/records/lexicon/runtime-dynamic-evaluation.md)
- [Compile-Time Evaluation / Build Complexity](https://banes-lab.com/records/tension/build-complexity-compile-time-evaluation.md)
- [Compile-Time Evaluation / Runtime Dynamic Evaluation](https://banes-lab.com/records/tension/compile-time-evaluation-runtime-dynamic-evaluation.md)
- [discouraged](https://banes-lab.com/records/vocabulary/severity-discouraged.md)
- [Safe Generation Boundary](https://banes-lab.com/records/lexicon/safe-generation-boundary.md)
- [Runtime Extensibility](https://banes-lab.com/records/architecture/runtime-extensibility.md)
- [Dynamic Optimization/Adaptation](https://banes-lab.com/records/lexicon/dynamic-optimization-adaptation.md)
- [Security/Debugging](https://banes-lab.com/records/lexicon/security-debugging.md)
- [Static Safety](https://banes-lab.com/records/lexicon/static-safety.md)
- [Runtime Code Generation / Security/Debugging](https://banes-lab.com/records/tension/runtime-code-generation-security-debugging.md)
- [Runtime Code Generation / Static Safety](https://banes-lab.com/records/tension/runtime-code-generation-static-safety.md)
- [Security Policy](https://banes-lab.com/records/algorithms/security-policy.md)
- [pattern](https://banes-lab.com/records/kind/pattern.md)
- [Formal Grammar/Semantics](https://banes-lab.com/records/lexicon/formal-grammar-semantics.md)
- [Declarative Configuration](https://banes-lab.com/records/architecture/declarative-configuration.md)
- [Ubiquitous Language](https://banes-lab.com/records/architecture/ubiquitous-language.md)
- [Domain Expressiveness](https://banes-lab.com/records/lexicon/domain-expressiveness.md)
- [Tooling/Maintenance](https://banes-lab.com/records/lexicon/tooling-maintenance.md)
- [General-Purpose Boilerplate](https://banes-lab.com/records/lexicon/general-purpose-boilerplate.md)
- [Domain-Specific Language (DSL) / Tooling/Maintenance](https://banes-lab.com/records/tension/domain-specific-language-dsl-tooling-maintenance.md)
- [approach](https://banes-lab.com/records/kind/approach.md)
- [Code Generation or Interpreters](https://banes-lab.com/records/lexicon/code-generation-or-interpreters.md)
- [Domain Modeling](https://banes-lab.com/records/lexicon/domain-modeling.md)
- [High-Level Domain Expression](https://banes-lab.com/records/lexicon/high-level-domain-expression.md)
- [Toolchain Complexity](https://banes-lab.com/records/lexicon/toolchain-complexity.md)
- [One-Size General-Purpose Code](https://banes-lab.com/records/lexicon/one-size-general-purpose-code.md)
- [Language-Oriented Programming / Toolchain Complexity](https://banes-lab.com/records/tension/language-oriented-programming-toolchain-complexity.md)
- [Language-Oriented Programming / One-Size General-Purpose Code](https://banes-lab.com/records/tension/language-oriented-programming-one-size-general-purpose-code.md)
- [Formal Model](https://banes-lab.com/records/lexicon/formal-model.md)
- [Transformation Rules](https://banes-lab.com/records/lexicon/transformation-rules.md)
- [Metadata-Driven Design](https://banes-lab.com/records/architecture/metadata-driven-design.md)
- [Generated Implementations](https://banes-lab.com/records/lexicon/generated-implementations.md)
- [Handwritten Divergence](https://banes-lab.com/records/lexicon/handwritten-divergence.md)

## Linked from

- [The layer topology](https://banes-lab.com/ontology/schema/the-layer-topology.md)
- [The membership](https://banes-lab.com/ontology/schema/the-membership.md)
