Skip to content

Commit bb18854

Browse files
committed
Wizards of Odd — initial public release
A live AI wizard-council app and a reference implementation of MetaObjects: one typed-metadata spine drives the Cloudflare D1 schema, the API types, the LLM prompts, and the SSE protocol, with a build-time drift gate. See README.md and docs/how-metaobjects-is-used.md.
0 parents  commit bb18854

250 files changed

Lines changed: 21005 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.claude/skills/metaobjects-audit/SKILL.md‎

Lines changed: 383 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
# MetaObjects capability checklist (registry-grounded)
2+
3+
The **exhaustive** list of every modelable MetaObjects capability, each with its one-line
4+
audit hunt: *"find a hand-written shape the metadata already describes."* Every
5+
`type.subtype` and every `@`-prefixed attribute named here is verbatim from the cross-port vocabulary in
6+
`fixtures/registry-conformance/expected-registry.json` (the
7+
`agent-context-capability-grounding.test.ts` guard fails the build if a line claims a token
8+
the registry lacks). Work this checklist on every axis so coverage is exhaustive; respect
9+
the **inline calibration flags** so a per-port gap is never scored as the adopter's fault.
10+
11+
How to use a line: the capability is what the metamodel can express; the hunt is the
12+
hand-written second-source-of-truth that should have been derived from it. Found one →
13+
classify it (using the classification scheme in `SKILL.md`) and route the cutover to the right sibling skill.
14+
15+
---
16+
17+
## Object — `object.*`
18+
19+
- **`object.entity`** (`@discriminator` / `@discriminatorValue` for STI/TPH) — hunt
20+
hand-written entity classes, DTOs, and repositories whose field list duplicates a modeled
21+
entity; hand-rolled single-table-inheritance / type-discriminator switches that
22+
`@discriminator`+`@discriminatorValue` already model.
23+
- **`object.value`** — hunt hand-authored request / command / payload value objects (no
24+
identity, no source) that restate a modeled `value` shape.
25+
- **`object.projection`** — hunt hand-written read-model DTOs and the SQL views behind them
26+
that a derived read-only projection (extends + origin-derived fields) already describes.
27+
- **`object.base`** — abstract base; hunt copy-pasted shared field blocks that should be an
28+
abstract base + `extends` (see cross-cutting).
29+
30+
## Field — `field.*`
31+
32+
- **`field.string`** (`@maxLength`) — hunt hand-validated string-length checks the field
33+
models.
34+
- **`field.int` / `field.long` / `field.double` / `field.float`** — hunt ad-hoc numeric
35+
columns / parsing the subtype already types.
36+
- **`field.decimal`** (`@precision` / `@scale`) — hunt money or quantity stored as `float`/
37+
`double` (lossy); the decimal subtype carries exact precision/scale.
38+
- **`field.boolean`** — hunt int-or-string flags standing in for a boolean.
39+
- **`field.currency`** (`@currency`, + `view.currency` `@locale`) — hunt money as float,
40+
hand `*100` / `/100` minor-unit math, or server-side `Intl.NumberFormat`; storage is
41+
integer minor units, formatting is client-side.
42+
- **`field.date` / `field.time` / `field.timestamp`** (`@autoSet`) — hunt hand-stamped
43+
`createdAt` / `updatedAt` assignments and ad-hoc temporal parsing; `@autoSet` stamps them.
44+
- **`field.enum`** (`@values`) — hunt hand-written TS unions, language `enum`s, or DB
45+
`CHECK ... IN (...)` lists that restate a modeled enum's members.
46+
- **`field.uuid`** — hunt UUIDs typed as bare strings / hand-validated.
47+
- **`field.object`** (`@objectRef`, `@storage`) — hunt hand-flattened owned columns or
48+
hand-rolled jsonb (de)serialization the `@storage` mode (`flattened`/`jsonb`/`subdocument`)
49+
already drives.
50+
- **`field.map`** (`@valueType`) — hunt ad-hoc open-keyed key/value bags stuffed into a jsonb
51+
column by hand.
52+
- **Common field attrs** — `@column` (hand column-name mapping), `@default` (hand default
53+
assignment), `@required` (hand presence checks), `@unique` (hand uniqueness), `@readOnly`
54+
(hand write-guards), `@filterable` / `@sortable` (hand filter/sort allowlists),
55+
`@dbColumnType` (hand native-type override), `@example` / `@instruction` (hand prompt
56+
hints), `@xmlText` (hand XML-text mapping). Indexed-without-filter suppression is the
57+
`db.indexed` attr (cite without the `@` sigil — it is a dotted attr name).
58+
- **CALIBRATION — cut subtypes:** `field.byte`, `field.short`, `field.class` are
59+
non-functional removed stubs. **Do NOT audit for them and never recommend them.**
60+
61+
## Source — `source.rdb`
62+
63+
- **`source.rdb`** (`@table`, `@schema`) — hunt hard-coded physical table/schema names that
64+
diverge from the default naming the source models.
65+
- **`@kind` = `view` / `materializedView`** — hunt hand-written SQL views where an authored
66+
projection source (read-only `@kind`) belongs.
67+
- **`@kind` = `storedProc` / `tableFunction`** (`@parameterRef`) — hunt hand-called procs /
68+
table functions that a modeled callable source with `@parameterRef` already describes.
69+
- **`@role` = `primary`** (multi-source write-through) — hunt manual CQRS / write-through
70+
wiring; exactly one `primary` source per object models it.
71+
- **`source.base`** — abstract source base (no audit target of its own).
72+
73+
## Relationship — `relationship.*`
74+
75+
- **1:N / N:1** (`@cardinality`, `@objectRef`) — hunt hand-written FK joins and type-unsafe
76+
finders the cardinality + target reference already model.
77+
- **M:N** (`@through`) — hunt hand junction-table queries where `@through` + the junction's
78+
two `identity.reference` children generate the traversal.
79+
- **Self-join** (`@symmetric`, `@sourceRefField`) — hunt hand-coded self-join / graph queries
80+
that an undirected (`@symmetric`) or directed (`@sourceRefField`) self-relationship models.
81+
- **Referential actions** (`@onDelete`, `@onUpdate`) — hunt app-code cascade/null-out logic
82+
the relationship's referential actions express.
83+
- **`relationship.association` / `relationship.aggregation` / `relationship.composition`** —
84+
hunt ownership/lifecycle semantics (delete-with-parent, shared vs owned) coded by hand
85+
instead of by the relationship subtype.
86+
- **`relationship.base`** — abstract base.
87+
88+
## Identity — `identity.*`
89+
90+
- **`identity.primary`** (`@generation`) — hunt hand-assigned primary keys / ID generation
91+
the primary identity's `@generation` strategy models.
92+
- **`identity.secondary`** (`@fields`; physical escapes `@using`/`@expr`/`@where`/`@orders`) — a
93+
UNIQUE alternate key (uniqueness is the type — the legacy `@unique` attr was removed from it);
94+
hunt hand-rolled unique constraints or raw-SQL partial/functional unique indexes it models.
95+
- **`identity.reference`** (`@references`, `@enforce`) — hunt hand-written FK constraints /
96+
reference enforcement the reference identity already declares.
97+
98+
## Index — `index.*` (non-unique retrieval)
99+
100+
- **`index.lookup`** (`@fields` required; physical escapes `@using`/`@expr`/`@where`/`@orders`) —
101+
a NON-unique retrieval index (uniqueness is what distinguishes it from `identity.secondary`);
102+
hunt hand-created lookup / recency indexes (`CREATE INDEX …`) it models.
103+
104+
## Origin — `origin.*` (projection-field derivation)
105+
106+
- **`origin.aggregate`** (`@agg`, `@of`, `@via`) — hunt hand `COUNT` / `SUM` / `AVG`
107+
subqueries or in-app rollups a derived aggregate field models.
108+
- **`origin.passthrough`** (`@from`, `@via`) — hunt denormalized-by-hand copied fields that a
109+
passthrough origin pulls across a relationship.
110+
- **`origin.collection`** (`@via`) — hunt hand-assembled child-collection loading a collection
111+
origin derives.
112+
- **`origin.base`** — abstract base.
113+
114+
## Validator — `validator.*`
115+
116+
- **`validator.required` / `validator.length` / `validator.numeric` / `validator.array` /
117+
`validator.regex`** — hunt hand field-level validation (presence, length, numeric range,
118+
array bounds, `@pattern` regex) the validator subtypes model.
119+
- **Cross-field validators** — `validator.comparison` (`@left`/`@op`/`@right`, e.g.
120+
"end ≥ start"), `validator.atLeastOne` (one-of-N present), `validator.requiredWhen`
121+
(conditional-required), `validator.presentIff` (mutual presence). Hunt these as hand-coded
122+
multi-field rules — they ARE modelable (see the Semantic-constraint ratification section in
123+
`SKILL.md` to decide what belongs in shared metadata vs port-local).
124+
- **`validator.base`** — abstract base.
125+
126+
## View / Layout — `view.*`, `layout.*`
127+
128+
- **`view.currency`** (`@locale`) — hunt hand-passed currency locale / `Intl.NumberFormat`
129+
options the currency view models. **Cross-port-gated** (with `view.base`).
130+
- **`layout.dataGrid`** (`@columns`, `@defaultSortField`, `@defaultSortOrder`, `@pageSize`) —
131+
hunt hand-written grid column definitions + data hooks a data-grid layout generates.
132+
- **CALIBRATION — TS/web-only:** the `view.*` widget subtypes exist only for TS/web consumers
133+
and are NOT in the cross-port registry — `view.text`, `view.textarea`, `view.date`,
134+
`view.month`, `view.hotlink`, `view.dropdown`, `view.radio`, `view.checkbox`, `view.number`,
135+
`view.password`, `view.hidden`, `view.web`. **Audit these only for TS adopters.** Only
136+
`view.base` / `view.currency` are cross-port-gated.
137+
138+
## Template — `template.*` (prompt pillar)
139+
140+
- **`template.prompt`** (`@payloadRef`, `@textRef`, `@responseRef`, `@requiredSlots`,
141+
`@maxTokens`, `@maxChars`, `@format`, `@model`, `@promptStyle`) — hunt prompt strings
142+
assembled inline in services, payloads built ad-hoc, output parsing without a typed
143+
`@responseRef`, or token/char budgets enforced by hand.
144+
- **`template.output`** (`@kind` = `document` | `email`; `@subjectRef`, `@htmlBodyRef`,
145+
`@textBodyRef`) — hunt hand-built document/email rendering + hand-written
146+
parse-on-receipt the output template + generated render helper/parser cover.
147+
- **`template.toolcall`** (`@toolName`, `@payloadRef`) — hunt hand-declared LLM tool schemas
148+
a modeled tool call describes.
149+
- **`template.base`** — abstract base.
150+
151+
## Attr — `attr.*`
152+
153+
- **`attr.properties`** — the sanctioned author key/value escape hatch; hunt ad-hoc metadata
154+
stuffed into code comments / side-maps that could instead ride the properties bag.
155+
- **`attr.filter`** — hunt hand-maintained preset filter definitions a modeled filter attr
156+
holds.
157+
- **`attr.class`** — binding facet (`field.class` binding); hunt hand-wired type-binding
158+
facets. (`attr.base`, `attr.string`, `attr.int`, `attr.long`, `attr.double`, `attr.boolean`
159+
are the value-type primitives behind typed attrs — not direct audit targets.)
160+
161+
## Common documentation attrs (any node)
162+
163+
- `@description`, `@title`, `@summary`, `@notes`, `@deprecated`, `@replacedBy`, `@seeAlso`,
164+
`@aliases` — hunt weak/absent generated docs and deprecation tracked only in code comments;
165+
these doc attrs flow into JSDoc / XML-doc / Postgres `COMMENT` / Mermaid doc-gen, and
166+
`@deprecated` / `@replacedBy` model lifecycle the codebase tracks by hand. (`@notes` is the
167+
internal-only rationale slot — never emitted to user-facing doc-gen.)
168+
169+
## Cross-cutting
170+
171+
- **`extends`** (any depth, cross-package `::`) — hunt copy-pasted base-entity field blocks
172+
that should be an abstract base inherited via `extends` (the inheritance mechanism;
173+
`origin.*` never inherits).
174+
- **Filter + sort + pagination REST layer** — hunt hand-written query parsing, `LIMIT`/
175+
`OFFSET` pagination, total-count queries, and filter/sort handling the generated CRUD layer
176+
(8 filter operators + sort + `?limit=N&offset=N` + count) already provides.
177+
- **CALIBRATION — per-port codegen gaps:** filter-operator route codegen is full only in
178+
**TS**; Java / Kotlin / C# / Python generate pagination/sort/count but **defer filter
179+
ops** — do NOT flag hand-added filter handling there. Output-parser codegen ships
180+
TS/C#/Python/Kotlin; **Java hand-writes** the Jackson parse (acceptable). **Python**
181+
still hand-wires the FastAPI router around a generated `APIRouter` (relationship /
182+
non-`table` source-kind / flattened-object codegen is partial). **C#** has no
183+
ObjectManager runtime tier (EF Core *is* the runtime) — hand services over the generated
184+
`DbContext` are expected.
185+
- **Single-source config** — `apiPrefix` (URL prefix wired into routes + hooks) and
186+
`columnNamingStrategy` (snake_case / literal / kebab-case) and per-target output dirs:
187+
hunt these values hard-coded in multiple places instead of resolved from config.
188+
- **CALIBRATION — planned, not yet shipped:** the declared-API surface (`api.base`,
189+
`api.operational`, `operation.query`, `operation.command`, `binding.rest`) and MCP exposure
190+
of declared prompts/tools are **not yet in the registry** — their absence is not an adopter
191+
defect; do NOT audit for them.
192+
- **CALIBRATION — cross-port version skew is by design:** TS/C#/Python on the `0.x` line vs
193+
Java/Kotlin on the `7.x` Maven line is correct — **never flag it.** Flag only *intra-port*
194+
version drift (mixed package versions within one port, or a runtime package in
195+
`devDependencies`). Trust the port docs + `meta gen --list`, not stale upstream prose
196+
(e.g. the out-of-date "hand-write the Spring controller" note — controllers ARE generated).
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# TypeScript port — audit reference
2+
3+
TypeScript is the **reference implementation**. Codegen, schema migration, docs,
4+
and live-DB drift all run through the Node `meta` CLI (`@metaobjectsdev/cli`,
5+
binary `meta`). The full feature set ships here; other ports are measured against it.
6+
7+
---
8+
9+
## Finding generated files
10+
11+
Generated files carry the header:
12+
13+
```
14+
// @generated by @metaobjectsdev/codegen-ts
15+
```
16+
17+
The runner **only overwrites files bearing this header** — hand-edited sibling
18+
files (`<Entity>.extra.ts`) are never touched. Locate generated output at the
19+
`outDir` (and per-target `outDir` values) declared in `metaobjects.config.ts`. With
20+
the default single-target config, generated files land at the one configured
21+
`outDir` (e.g. `src/generated/`).
22+
23+
---
24+
25+
## Run codegen + verify
26+
27+
```bash
28+
meta gen # render → 3-way merge → write (overwrites @generated files only)
29+
meta gen --dry-run # preview without writing
30+
meta gen Author Post # scope to named entities
31+
meta verify --codegen # regenerate to temp, diff vs committed output
32+
meta verify --templates # check {{field}} refs vs payload VO (bare `meta verify` default)
33+
meta verify --db # schema drift — live DB vs metadata (requires DB connection)
34+
meta verify --codegen --templates --db # all three drift checks in one pass
35+
```
36+
37+
`meta gen` and a real `meta verify` run also emit an **advisory anti-pattern pass**
38+
(never fails the build) flagging hand-rolled aggregates, money-as-float, and CHECK
39+
value-sets against the constructs that replace them.
40+
41+
---
42+
43+
## Drift signatures (what to grep for)
44+
45+
| Signature | What it means |
46+
|---|---|
47+
| `pgTable(` / `sqliteTable(` outside `src/generated/` | hand-authored Drizzle table — candidate to generate |
48+
| `z.object({` / `z.string()` in service/route files | hand-built Zod schema — compare to generated `InsertSchema`/`UpdateSchema` |
49+
| `FilterAllowlist` defined by hand | should be the generated `<Entity>FilterAllowlist` |
50+
| `// keep in sync with` / `// mirrors the` | second-source-of-truth comment — always a finding |
51+
| camelCase↔snake_case mapping tables | generated views handle this; diff field by field |
52+
| `@generated` file with hand edits | three-way merge preserves them; review at codegen; never delete |
53+
54+
---
55+
56+
## Owned generators — scaffold-and-own (ADR-0034)
57+
58+
`meta init` copies the reference generator templates into the project at
59+
`codegen/generators/*.ts`. The scaffolded `metaobjects.config.ts` imports the
60+
**owned** local copies:
61+
62+
```ts
63+
import { entityFile } from "./codegen/generators/entity";
64+
import { queriesFile } from "./codegen/generators/queries";
65+
```
66+
67+
**Deprecated import path** (still works, removal planned):
68+
69+
```ts
70+
import { entityFile, queriesFile, routesFile, barrel } from "@metaobjectsdev/codegen-ts/generators";
71+
```
72+
73+
**Finding this in a project:** grep for the deprecated path:
74+
75+
```bash
76+
grep -r '@metaobjectsdev/codegen-ts/generators' .
77+
```
78+
79+
A hit means the project has not adopted scaffold-and-own — recommend `meta init`
80+
to scaffold the owned copies. The owned generator files themselves (`codegen/generators/*.ts`)
81+
are the second thing to audit: are they stale relative to the reference templates,
82+
or intentionally customized?
83+
84+
---
85+
86+
## Version-skew check
87+
88+
The resolved CLI version is what actually ran codegen — check `node_modules`, not
89+
`package.json` declared ranges:
90+
91+
```bash
92+
npm list @metaobjectsdev/cli @metaobjectsdev/codegen-ts @metaobjectsdev/metadata
93+
```
94+
95+
All `@metaobjectsdev/*` packages publish in lockstep. A mixed resolved version
96+
(e.g. `codegen-ts@0.12.0` alongside `metadata@0.11.9`) is an intra-port skew
97+
finding. A runtime package (`@metaobjectsdev/runtime-ts`) in `devDependencies`
98+
rather than `dependencies` is also a finding — it ships to the deployed app.
99+
This intra-port skew is npm-vs-npm; **cross-language** skew (a stale npm line next to
100+
a newer Maven/PyPI/NuGet line) is invisible in the package numbers and must be checked
101+
via `metamodelVersion` (see the Phase 0 cross-language consistency item).
102+
103+
---
104+
105+
## Calibration gaps (do NOT flag these)
106+
107+
TypeScript is the reference implementation — it ships the full feature set:
108+
109+
- Filter-operator codegen: **complete** (`<Entity>FilterAllowlist`, 8 operators, all four CRUD routes validate against it).
110+
- Output-parser codegen: **complete** (`outputParser()` generator; `parse*`/`safeParse*`/`extract*` per `template.output`).
111+
- ObjectManager: **complete** (`@metaobjectsdev/runtime-ts`; `kyselyDriver` / `inMemoryDriver`).
112+
- Schema migrate / `meta verify --db`: **complete** (TS owns the shared migrate engine — ADR-0015).
113+
- D1 dialect: **TS-only by design** — `dialect: "d1"` in `metaobjects.config.ts` targets Cloudflare D1 via the Wrangler CLI layout. Do NOT recommend porting D1 support to other languages.

0 commit comments

Comments
 (0)