Skip to content

Commit 4b90500

Browse files
committed
feat(metamodel): ADR-0036 Wave 3 — field.uri, field.inet subtypes + @stringformat (TS reference)
Implements the TypeScript reference for ADR-0036 decision #2 / ADR-0037: two new field subtypes (concepts with a native type + behavior) and one new validation attribute (a plain validated string). Metamodel (spec/metamodel/field.json + regenerated embed): - field.uri — a URI/URL string. TS binds to `string` (no native URI type, same as field.uuid); other ports bind native URI. DB column = text. Ships WITHOUT @kind in v1 (native type subsumes url/urn). - field.inet — an IP-address string (v4/v6). TS binds to `string`; other ports bind native IP. DB column = Postgres-native `inet`. Ships WITHOUT @kind in v1. - @stringformat on field.string — closed set {email|hostname}; the field stays a plain string, codegen owns the canonical matcher. Named distinctly to avoid colliding with template.* @Format. Constants + runtime: FIELD_SUBTYPE_URI/INET, FIELD_ATTR_STRING_FORMAT + STRING_FORMAT_EMAIL/HOSTNAME; FIELD_DATA_TYPE binds uri/inet → string; op-bands (uri = string-like eq/ne/in/like/isNull; inet = uuid-like eq/ne/in/isNull). codegen-ts: - column-mapper: uri → text, inet → inet (Drizzle pg-core native inet()), both text on SQLite; native TS binding stays string. - Zod: field.uri → z.string().url(); field.inet → z.string().ip(); @stringformat email → z.string().email(); hostname → codegen-owned canonical hostname regex (not author validator.regex). - inferred-types / field-meta / fr010 field-mapping: uri/inet → string scalar. migrate-ts (schema DDL stays TS-owned): SqlType gains `inet`; uri → text, inet → INET (Postgres) / TEXT (SQLite); introspect maps inet back. Goldens regenerated: registry-conformance expected-registry.json (uri/inet entries + @stringformat allowedValues), coverage-report.json baseline, metamodel-docs. New conformance fixture field-uri-inet-stringformat gates the new vocab through the loader under strict mode. Other 4 ports must replicate the shared golden + bind the NATIVE type per port (Java java.net.URI / InetAddress, C# System.Uri / IPAddress, Python urllib / ipaddress, Kotlin via JVM) and emit idiomatic validation. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GF9xLEQZaPus5Y6opk398n
1 parent cf70774 commit 4b90500

25 files changed

Lines changed: 738 additions & 10 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"metadata.root": {
3+
"package": "acme",
4+
"children": [
5+
{
6+
"object.entity": {
7+
"name": "Endpoint",
8+
"children": [
9+
{
10+
"field.uuid": {
11+
"name": "id"
12+
}
13+
},
14+
{
15+
"field.uri": {
16+
"name": "webhookUrl"
17+
}
18+
},
19+
{
20+
"field.inet": {
21+
"name": "sourceIp"
22+
}
23+
},
24+
{
25+
"field.string": {
26+
"name": "contactEmail",
27+
"@stringFormat": "email"
28+
}
29+
},
30+
{
31+
"field.string": {
32+
"name": "host",
33+
"@stringFormat": "hostname"
34+
}
35+
},
36+
{
37+
"identity.primary": {
38+
"name": "id",
39+
"@fields": [
40+
"id"
41+
]
42+
}
43+
}
44+
]
45+
}
46+
}
47+
]
48+
}
49+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"metadata.root": {
3+
"package": "acme",
4+
"children": [
5+
{
6+
"object.entity": {
7+
"name": "Endpoint",
8+
"children": [
9+
{
10+
"field.uuid": {
11+
"name": "id"
12+
}
13+
},
14+
{
15+
"field.uri": {
16+
"name": "webhookUrl"
17+
}
18+
},
19+
{
20+
"field.inet": {
21+
"name": "sourceIp"
22+
}
23+
},
24+
{
25+
"field.string": {
26+
"name": "contactEmail",
27+
"@stringFormat": "email"
28+
}
29+
},
30+
{
31+
"field.string": {
32+
"name": "host",
33+
"@stringFormat": "hostname"
34+
}
35+
},
36+
{
37+
"identity.primary": {
38+
"name": "id",
39+
"@fields": [
40+
"id"
41+
]
42+
}
43+
}
44+
]
45+
}
46+
}
47+
]
48+
}
49+
}

‎fixtures/metamodel-docs/expected/INDEX.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@ children, and cardinality of a subtype. Universal documentation attributes
3232
| `field.double` | Double-precision (64-bit) IEEE-754 floating point. Binds to the native double/number type; DB column is DOUBLE PRECISION. Not for money — use field.currency or field.decimal. | [types/field.md#fielddouble](types/field.md#fielddouble) |
3333
| `field.enum` | String-backed enumeration constrained to a closed set of member symbols (@values). Each member is its own stored string with no name/value divergence. | [types/field.md#fieldenum](types/field.md#fieldenum) |
3434
| `field.float` | Single-precision floating point. Binds to the native double/number type (TS has no distinct float); DB column is REAL. Not for money. | [types/field.md#fieldfloat](types/field.md#fieldfloat) |
35+
| `field.inet` | An IP-address string (IPv4 or IPv6) (ADR-0036/0037 — a concept with a native type + behavior, so a subtype not a @stringFormat). Binds to TS string (TS has no native IP type, same as field.uuid); other ports bind to their native IP type (Java java.net.InetAddress, C# System.Net.IPAddress, Python ipaddress, Kotlin java.net.InetAddress). DB column is the Postgres-native inet type. Codegen emits an IP validator accepting both v4 and v6 (TS Zod z.string().ip()). v1 ships WITHOUT @kind — the native type subsumes ipv4/ipv6; @kind is reserved for a later ipv4\|ipv6 value-constraint. | [types/field.md#fieldinet](types/field.md#fieldinet) |
3536
| `field.int` | 32-bit signed integer. Binds to the native int type; DB column is INTEGER. | [types/field.md#fieldint](types/field.md#fieldint) |
3637
| `field.long` | 64-bit signed integer. Binds to the native long/bigint type; DB column is BIGINT. | [types/field.md#fieldlong](types/field.md#fieldlong) |
3738
| `field.map` | An open-keyed map (Record<string,V> / dict[str,V]) stored in a single jsonb column. Keys are always strings (the JSON object constraint); the value type is set by @valueType (a scalar field subtype) or @objectRef (a value-object). | [types/field.md#fieldmap](types/field.md#fieldmap) |
3839
| `field.object` | A nested structured value (set @objectRef to the target object). Storage is governed by @storage: flattened (prefixed columns), jsonb (single jsonb column, supports isArray), or subdocument (document-store hint). | [types/field.md#fieldobject](types/field.md#fieldobject) |
3940
| `field.string` | Variable-length text. Binds to the native string type; DB column is VARCHAR/TEXT (use @maxLength for VARCHAR(n)). | [types/field.md#fieldstring](types/field.md#fieldstring) |
4041
| `field.time` | Time-of-day (no calendar date). Binds to the native date/temporal type; DB column is TIME. | [types/field.md#fieldtime](types/field.md#fieldtime) |
4142
| `field.timestamp` | Date + time-of-day instant (optionally with timezone). Binds to the native date/temporal type; DB column is TIMESTAMP(TZ). Pair with @autoSet for created/updated stamping. | [types/field.md#fieldtimestamp](types/field.md#fieldtimestamp) |
43+
| `field.uri` | A URI/URL string (ADR-0036/0037 — a concept with a native type + behavior, so a subtype not a @stringFormat). Binds to TS string (TS has no native URI type, same as field.uuid); other ports bind to their native URI type (Java java.net.URI, C# System.Uri, Python urllib.parse, Kotlin java.net.URI) and parse scheme/authority/path. DB column is text (Postgres has no uri type). Codegen emits a URL/URI validator (TS Zod z.string().url()). v1 ships WITHOUT @kind — the native type subsumes url/urn; @kind is reserved for a later url\|urn value-constraint. | [types/field.md#fielduri](types/field.md#fielduri) |
4244
| `field.uuid` | Logical UUID identity scalar. A bare scalar (no required attrs, no loader value-validation) — binds to TS string (no native UUID type); DB column is Postgres-native uuid. | [types/field.md#fielduuid](types/field.md#fielduuid) |
4345
| `identity.primary` | The primary key — one per entity; @fields names its column(s), @generation the value strategy. | [types/identity.md#identityprimary](types/identity.md#identityprimary) |
4446
| `identity.reference` | A foreign-key reference to another entity (@references target; @enforce toggles a physical FK). | [types/identity.md#identityreference](types/identity.md#identityreference) |

‎fixtures/metamodel-docs/expected/providers.md‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ provider owns. This is the ownership lens over the same vocabulary
1313

1414
Core metaobjects metamodel types and subtypes.
1515

16-
**Owns (registers):** `attr.base`, `attr.boolean`, `attr.class`, `attr.double`, `attr.filter`, `attr.int`, `attr.long`, `attr.properties`, `attr.string`, `field.base`, `field.boolean`, `field.currency`, `field.date`, `field.decimal`, `field.double`, `field.enum`, `field.float`, `field.int`, `field.long`, `field.map`, `field.object`, `field.string`, `field.time`, `field.timestamp`, `field.uuid`, `identity.primary`, `identity.reference`, `identity.secondary`, `layout.base`, `layout.dataGrid`, `object.base`, `object.entity`, `object.projection`, `object.value`, `origin.aggregate`, `origin.base`, `origin.collection`, `origin.passthrough`, `relationship.aggregation`, `relationship.association`, `relationship.base`, `relationship.composition`, `source.base`, `source.rdb`, `template.base`, `template.output`, `template.prompt`, `template.toolcall`, `validator.array`, `validator.atLeastOne`, `validator.base`, `validator.comparison`, `validator.length`, `validator.numeric`, `validator.presentIff`, `validator.regex`, `validator.required`, `validator.requiredWhen`, `view.base`, `view.currency`
16+
**Owns (registers):** `attr.base`, `attr.boolean`, `attr.class`, `attr.double`, `attr.filter`, `attr.int`, `attr.long`, `attr.properties`, `attr.string`, `field.base`, `field.boolean`, `field.currency`, `field.date`, `field.decimal`, `field.double`, `field.enum`, `field.float`, `field.inet`, `field.int`, `field.long`, `field.map`, `field.object`, `field.string`, `field.time`, `field.timestamp`, `field.uri`, `field.uuid`, `identity.primary`, `identity.reference`, `identity.secondary`, `layout.base`, `layout.dataGrid`, `object.base`, `object.entity`, `object.projection`, `object.value`, `origin.aggregate`, `origin.base`, `origin.collection`, `origin.passthrough`, `relationship.aggregation`, `relationship.association`, `relationship.base`, `relationship.composition`, `source.base`, `source.rdb`, `template.base`, `template.output`, `template.prompt`, `template.toolcall`, `validator.array`, `validator.atLeastOne`, `validator.base`, `validator.comparison`, `validator.length`, `validator.numeric`, `validator.presentIff`, `validator.regex`, `validator.required`, `validator.requiredWhen`, `view.base`, `view.currency`
1717

1818
**Contributes attributes:**
1919

@@ -23,7 +23,7 @@ Core metaobjects metamodel types and subtypes.
2323
- `field.enum`: `@provided`, `@values`
2424
- `field.map`: `@objectRef`, `@valueType`
2525
- `field.object`: `@objectRef`
26-
- `field.string`: `@maxLength`
26+
- `field.string`: `@maxLength`, `@stringFormat`
2727
- `identity.primary`: `@fields`, `@generation`
2828
- `identity.reference`: `@enforce`, `@fields`, `@references`
2929
- `identity.secondary`: `@fields`, `@unique`
@@ -59,13 +59,15 @@ DB-domain attributes — @column / @db.indexed / @dbColumnType on every field, @
5959
- `field.double`: `@column`, `@db.indexed`, `@dbColumnType`
6060
- `field.enum`: `@column`, `@db.indexed`, `@dbColumnType`
6161
- `field.float`: `@column`, `@db.indexed`, `@dbColumnType`
62+
- `field.inet`: `@column`, `@db.indexed`, `@dbColumnType`
6263
- `field.int`: `@column`, `@db.indexed`, `@dbColumnType`
6364
- `field.long`: `@column`, `@db.indexed`, `@dbColumnType`
6465
- `field.map`: `@column`, `@db.indexed`, `@dbColumnType`
6566
- `field.object`: `@column`, `@db.indexed`, `@dbColumnType`, `@storage`
6667
- `field.string`: `@column`, `@db.indexed`, `@dbColumnType`
6768
- `field.time`: `@autoSet`, `@column`, `@db.indexed`, `@dbColumnType`
6869
- `field.timestamp`: `@autoSet`, `@column`, `@db.indexed`, `@dbColumnType`, `@localTime`
70+
- `field.uri`: `@column`, `@db.indexed`, `@dbColumnType`
6971
- `field.uuid`: `@column`, `@db.indexed`, `@dbColumnType`
7072
- `identity.reference`: `@constraintName`
7173
- `identity.secondary`: `@expr`, `@orders`, `@using`, `@where`
@@ -91,13 +93,15 @@ Prompt / AI + serialization domain — @xmlText / @example / @instruction field
9193
- `field.double`: `@example`, `@instruction`, `@xmlText`
9294
- `field.enum`: `@coerceDefault`, `@enumAlias`, `@enumDoc`, `@example`, `@instruction`, `@normalize`, `@xmlText`
9395
- `field.float`: `@example`, `@instruction`, `@xmlText`
96+
- `field.inet`: `@example`, `@instruction`, `@xmlText`
9497
- `field.int`: `@example`, `@instruction`, `@xmlText`
9598
- `field.long`: `@example`, `@instruction`, `@xmlText`
9699
- `field.map`: `@example`, `@instruction`, `@xmlText`
97100
- `field.object`: `@example`, `@instruction`, `@xmlText`
98101
- `field.string`: `@example`, `@instruction`, `@xmlText`
99102
- `field.time`: `@example`, `@instruction`, `@xmlText`
100103
- `field.timestamp`: `@example`, `@instruction`, `@xmlText`
104+
- `field.uri`: `@example`, `@instruction`, `@xmlText`
101105
- `field.uuid`: `@example`, `@instruction`, `@xmlText`
102106
- `object.value`: `@normalize`
103107
- `template.output`: `@format`, `@htmlBodyRef`, `@kind`, `@maxChars`, `@owner`, `@payloadRef`, `@promptStyle`, `@requiredTags`, `@since`, `@subjectRef`, `@textBodyRef`, `@textRef`
@@ -118,13 +122,15 @@ UI/query-surface domain — @filterable / @sortable / @sortableDefaultOrder fiel
118122
- `field.double`: `@filterable`, `@sortable`, `@sortableDefaultOrder`
119123
- `field.enum`: `@filterable`, `@sortable`, `@sortableDefaultOrder`
120124
- `field.float`: `@filterable`, `@sortable`, `@sortableDefaultOrder`
125+
- `field.inet`: `@filterable`, `@sortable`, `@sortableDefaultOrder`
121126
- `field.int`: `@filterable`, `@sortable`, `@sortableDefaultOrder`
122127
- `field.long`: `@filterable`, `@sortable`, `@sortableDefaultOrder`
123128
- `field.map`: `@filterable`, `@sortable`, `@sortableDefaultOrder`
124129
- `field.object`: `@filterable`, `@sortable`, `@sortableDefaultOrder`
125130
- `field.string`: `@filterable`, `@sortable`, `@sortableDefaultOrder`
126131
- `field.time`: `@filterable`, `@sortable`, `@sortableDefaultOrder`
127132
- `field.timestamp`: `@filterable`, `@sortable`, `@sortableDefaultOrder`
133+
- `field.uri`: `@filterable`, `@sortable`, `@sortableDefaultOrder`
128134
- `field.uuid`: `@filterable`, `@sortable`, `@sortableDefaultOrder`
129135
- `layout.dataGrid`: `@columns`, `@defaultSortField`, `@defaultSortOrder`, `@filter`, `@filterable`, `@pageSize`
130136
- `view.currency`: `@locale`

0 commit comments

Comments
 (0)