Skip to content

Commit 363802e

Browse files
dmealingclaude
andcommitted
docs(agent-context): refresh the MetaObjects skills to 0.24.2
The scaffolded agent context was generated by 0.15.18 and had not moved since the initial public release, so every `meta gen` / `meta verify` run printed a staleness nudge -- and anyone cloning this repo to see how MetaObjects is used was reading guidance nine minor lines out of date. `meta init --docs-only --refresh-docs` rewrites all 16 scaffolded files from the installed CLI. Nothing here was hand-edited (the context stamp records a hash per file for exactly that reason), so this is a clean overwrite: +1209/-216 across the six skills plus AGENTS.md/CLAUDE.md, and the stamp now reads 0.24.2. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NynrRND6ZUwGvq3ZUTCfxG
1 parent 9fb9655 commit 363802e

14 files changed

Lines changed: 1212 additions & 219 deletions

File tree

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

Lines changed: 145 additions & 10 deletions
Large diffs are not rendered by default.

‎.claude/skills/metaobjects-audit/references/capability-checklist.md‎

Lines changed: 128 additions & 28 deletions
Large diffs are not rendered by default.

‎.claude/skills/metaobjects-audit/references/typescript.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ via `metamodelVersion` (see the Phase 0 cross-language consistency item).
106106

107107
TypeScript is the reference implementation — it ships the full feature set:
108108

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`).
109+
- Filter-operator codegen: **complete** — the core `?filter[field][op]` grammar (all 9 operators `eq/ne/gt/gte/lt/lte/in/like/isNull`, `<Entity>FilterAllowlist`) generates in every port; TS additionally ships the richer surface (`?search=`, `filter[or][N]` / `filter[and][N]` combinators, leading-wildcard gating).
110+
- Output-parser codegen: **complete** (`outputParser()` generator; `parse*`/`safeParse*`/`extract*` emitted as `<Name>.response.ts` per **responding `template.prompt`** — one carrying `@responseRef`; ADR-0052).
111111
- ObjectManager: **complete** (`@metaobjectsdev/runtime-ts`; `kyselyDriver` / `inMemoryDriver`).
112112
- Schema migrate / `meta verify --db`: **complete** (TS owns the shared migrate engine — ADR-0015).
113113
- 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.

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

Lines changed: 402 additions & 57 deletions
Large diffs are not rendered by default.

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

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,14 @@ Every emitted file carries a `@generated` header. This is load-bearing:
4545

4646
Practical rule: **pattern-derivable-from-metadata = regenerate; business logic =
4747
hand-write in a non-generated file.** FK columns, CRUD, validator chains,
48-
type-safe finders, `relations()` blocks — all derived, never hand-coded. Custom
49-
SQL views, regex from outside metadata, and domain logic are what you hand-write.
48+
type-safe finders, `relations()` blocks — all derived, never hand-coded. What you
49+
hand-write is what metadata genuinely can't express: regex from outside metadata and
50+
domain logic. Most views are NOT irreducible — model them as an `object.projection`
51+
and the view DDL is generated (see the projection bullet below); a hand-written view
52+
for a shape origins can express is drift the drift gate can't even see. A genuinely
53+
*irreducible* view body (recursive CTE, window function, set op) isn't hand-written
54+
loose either — it goes in the `source.rdb` **`@sql`** escape (#208, ADR-0043) so the
55+
tool still registers, fingerprints, and drift-checks it (see the projection bullet).
5056

5157
## Selecting generators by stable name
5258

@@ -55,8 +61,9 @@ name** (kebab-case) that surfaces in diagnostics — reference generators by tha
5561
name, never by inlining what they emit. Typical generators cover: the entity
5662
type/model, the DB table/schema, query/finder helpers, REST routes, client
5763
form/grid/hook artifacts, filter + sort allowlists, payload value-objects, and
58-
`template.output` parsers. You enable the subset your project needs; an abstract
59-
entity never emits instance/write artifacts regardless.
64+
parsers for a responding `template.prompt` (one carrying `@responseRef`). You
65+
enable the subset your project needs; an abstract entity never emits
66+
instance/write artifacts regardless.
6067

6168
Per-entity opt-outs exist (e.g. skipping client-side artifacts for a given
6269
entity) and are set as attributes on the entity in metadata, not in code.
@@ -77,15 +84,50 @@ the data access too.
7784
standard verbs with the runtime helpers and hand-write only the custom ones (see
7885
the runtime skill's `mountCrudRoutes` / `mount<Verb>Route` / `expose`). You are
7986
never forced into all-generated or all-hand-written.
87+
- **Entity's OWN columns + a joined extra → an entity read-view, NOT a projection.**
88+
The most common legacy view is `SELECT o.*, c.name AS customer_name FROM orders o
89+
JOIN customers c …` — the entity *with a read route*, not an independent exposure.
90+
Reach for an **entity read-view** first: keep the entity's writable `table` source
91+
and add a **non-primary** read-only source (`source.rdb` `@role: replica`
92+
`@kind: view`), declaring only the *extra* as a derived (`origin.*`) field — the
93+
entity's own field set already covers `o.*`, so you re-state nothing but the extra.
94+
Codegen then routes **reads** to the view and **writes** to the table (derived
95+
fields don't exist there and are excluded from the write codecs); a create/update
96+
re-reads the row through the view by primary key, so the returned value carries the
97+
derived columns (read-your-writes). Shipped all five ports (#213 write half + #214
98+
read half). Reach for a **projection** (below) instead only when it is an
99+
independent exposure contract — a subset, renamed base columns, a versioned/external
100+
shape, or a row-filtered view. See `docs/features/source-kinds.md`.
80101
- **Derived/aggregate data → declare a projection, then USE its generated query.**
81102
Don't hand-write a join or an `AVG()`/`COUNT()`. Declare an `object.projection`
82-
with `origin.aggregate` / `origin.passthrough` / `origin.collection` children
83-
**and a read-only `source.rdb` `@kind: view` child** (codegen detects a
84-
projection by that read-only source, not by the subtype alone — omit it and
85-
nothing is generated). `meta gen` emits a read-only query for it (and
86-
`meta migrate` its DB view), and you **call that generated query from your
87-
route**. Declaring the projection is only half the win — *consuming* its
88-
generated query is the other half.
103+
with `origin.*` children — `origin.passthrough` (a forwarded column),
104+
`origin.aggregate` (`@agg` `count`/`sum`/`avg`/`min`/`max`, plus the #195
105+
`any`/`all` predicate quantifiers over a `@filter` and `collect` array-rollup with
106+
optional `@distinct`/`@orderBy`; any aggregate may be row-scoped with `@filter`),
107+
`origin.computed` (a row-level `@expr`), and
108+
`origin.first` (one related row's column along `@via`/`@of`/`@orderBy`) — **and a
109+
read-only `source.rdb` `@kind: view` child** (codegen detects a projection by that
110+
read-only source, not by the subtype alone — omit it and nothing is generated).
111+
`meta gen` emits a read-only query for it (and `meta migrate` its DB view), and you
112+
**call that generated query from your route**. Declaring the projection is only half
113+
the win — *consuming* its generated query is the other half.
114+
- **Row-filtered views are a projection `@filter`, not hand-written SQL.** An
115+
object-level `@filter` on `object.projection` (the same `attr.filter` shape as a
116+
preset filter) scopes the whole view's rows — it lowers to the view's outer
117+
`WHERE` (#207). This is the metadata-managed way to author a soft-delete / status
118+
/ type view without hand-writing SQL.
119+
- **Never hand-author the view SQL for a shape origins can express.** The
120+
`CREATE VIEW` body is emitted by the Node `meta migrate` from the projection's
121+
`origin.*` children — hand-writing it is a second source of truth that drifts
122+
silently, because an unmodeled DB view is *unmanaged*: `meta verify --db` never
123+
flags it. For a genuinely irreducible body (recursive CTE, window function, set
124+
op) that origins can't express, carry it in the `source.rdb` **`@sql`** escape
125+
(#208, ADR-0043) — a hand-written body the tool registers, fingerprints, and
126+
drift-checks (adopt a pre-existing view with `meta migrate --allow adopt-view`) —
127+
rather than a hand-edited migration file where it goes accidentally unmanaged.
128+
For a DB object owned entirely elsewhere (Flyway), mark its source
129+
**`@unmanaged: true`** (view or table); migrate/verify then never touch it.
130+
`@sql` and `@unmanaged` are mutually exclusive.
89131

90132
`meta gen --list` prints every generator by stable name; the `generators` array in
91133
`metaobjects.config.ts` is where you opt each one in or out.

‎.claude/skills/metaobjects-codegen/references/typescript.md‎

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,17 @@ block, and the inferred types.
6767
A second file, `.metaobjects/config.json`, holds static project state parseable by
6868
non-TS tooling; `meta init` scaffolds both plus the `metaobjects/` source dir.
6969

70+
`sources` in that file is where the metadata lives — `metaobjects/` is only its
71+
DEFAULT value, so a project can point it anywhere. **Every entry is an OBJECT, never
72+
a bare string**, and it names a DIRECTORY or a file:
73+
74+
```jsonc
75+
{ "schema_version": 1, "sources": [{ "path": "model" }, { "path": "../shared/metadata" }] }
76+
```
77+
78+
Every command's directory argument (`meta docs <project-root>`, `--cwd`) is the
79+
PROJECT ROOT that CONTAINS the metadata — never the metadata directory itself.
80+
7081
## The generators
7182

7283
From `@metaobjectsdev/codegen-ts/generators` (server-side, framework-neutral):
@@ -78,7 +89,31 @@ From `@metaobjectsdev/codegen-ts/generators` (server-side, framework-neutral):
7889
| `routesFile()` | `<Entity>.routes.ts` — Fastify CRUD routes on the cross-port REST contract. `routesFileHono()` is the Hono/Workers variant. A TPH `@discriminator` base mounts polymorphic `GET /<base>(+/:id)` plus a per-subtype CRUD set at `<basePath>/<discriminatorValue lowercased>` — create omits the discriminator (the URL names the subtype; the runtime injects it); get/update/delete scoped to the subtype (cross-subtype → 404); discriminator immutable via the runtime `discriminator` option. |
7990
| `barrel()` | `index.ts` re-exporting each `<Entity>.ts` (one-shot, not per-entity) |
8091
| `promptRender()` | `render<Name>()` per `template.prompt` |
81-
| `outputParser()` | `<Name>.output.ts` (`parse*` / `safeParse*`) per `template.output` |
92+
| `outputParser()` | `<Name>.response.ts` (`parse*` / `safeParse*`) per **responding `template.prompt`** — one carrying `@responseRef` (ADR-0052: this tier is INBOUND; `template.output` is outbound only and emits nothing here). Siblings: `outputPrompt()` → `<Name>.responseFormat.ts` (the FR-010 output-format fragment, presentation via `@promptStyle`), `extractor()` → `<Name>.extractor.ts` (the tolerant `extract` mapper). |
93+
| `callableFile()` | `<Entity>.callable.ts` — an FR-015 `call<Entity>` wrapper for a `source.rdb` `@kind: storedProc`/`tableFunction` (args from the `@parameterRef` value object, in declaration order) |
94+
95+
**Projections (read-only views).** For an `object.projection` (a read-only `source.rdb`
96+
`@kind: view` child), `entityFile()` emits a `pgView(...)` + read-only Zod + a read-only
97+
finder (no create/update/delete). The `CREATE VIEW` DDL is generated by `meta migrate`
98+
from the projection's `origin.*` children — `origin.passthrough` (a forwarded column),
99+
`origin.aggregate` (`@agg` `count`/`sum`/`avg`/`min`/`max`, plus the #195 `any`/`all`
100+
predicate quantifiers over a `@filter` and `collect` array-rollup with optional
101+
`@distinct`/`@orderBy`; any aggregate row-scoped with `@filter`),
102+
`origin.computed` (a row-level `@expr`), `origin.first` (one related row's
103+
column along `@via`/`@of`/`@orderBy`). An object-level `@filter` on the projection scopes
104+
the whole view's rows (#207 — lowers to the outer `WHERE`, the metadata-managed
105+
soft-delete/status view). **Never hand-write the view SQL** for a shape origins can
106+
express (an unmodeled view is unmanaged and drifts silently); for a genuinely irreducible
107+
body (recursive CTE, window function, set op), carry it in the `source.rdb` **`@sql`**
108+
escape (#208) so the tool still owns it, or mark a Flyway-owned object `@unmanaged: true`.
109+
110+
**Entity read-view (write-through).** An `object.entity` that keeps its writable `table`
111+
primary source and adds a `@role: replica` `@kind: view` source is a write-through
112+
read-view (#214): `entityFile()` routes generated **reads** through the replica `pgView`
113+
(the read Zod carries the derived `origin.*` fields via `z.infer`), while `queriesFile()`
114+
writes target the table with derived fields excluded from the insert/update codecs; a
115+
create/update re-reads the row via the view by primary key (read-your-writes). The replica
116+
view's DDL is emitted by `meta migrate` from the same origin assembly as a projection view.
82117

83118
## Discriminator inheritance (TPH)
84119

@@ -98,10 +133,10 @@ cross-subtype 404. Conformance-gated by `fixtures/api-contract-conformance/tph`
98133
(HTTP wire shape) and `fixtures/persistence-conformance/tph-*` (single-table
99134
runtime semantics).
100135

101-
## Docs — `meta docs` (one door, two surfaces)
136+
## Docs — `meta docs` (one door, three surfaces)
102137

103138
Documentation is NOT a `meta gen` generator. The single door is the `meta docs`
104-
command, which emits two cross-linked **surfaces** under one output dir (default
139+
command, which emits three cross-linked **surfaces** under one output dir (default
105140
`./docs`):
106141

107142
- **model surface** (`./docs/<Entity>.md`, `./docs/<Template>.md`) — the neutral
@@ -111,11 +146,19 @@ command, which emits two cross-linked **surfaces** under one output dir (default
111146
`./docs/api/AGENT-API.md`) — the SDK/API reference: the concrete imports,
112147
function signatures, payload field shapes, and runnable examples for *this*
113148
project's generated code.
149+
- **requirements surface** (`./docs/requirements.md`, `./docs/requirements.toon`) —
150+
the declared `requirement.*` ledger as documentation, with each entry headed by its
151+
dotted path and its `title` where it has one, and each entity page naming the
152+
requirements that claim it. Metadata-alone like the model surface, so it needs no
153+
gen config. **On by default since 0.24.0** — a project declaring no `requirement.*`
154+
nodes writes no requirements file and the run says nothing about the surface at all,
155+
deliberately: reporting "0 requirement pages" would advertise a surface that never ran.
114156

115157
```bash
116-
npx meta docs # both surfaces → ./docs (model) + ./docs/api (api)
158+
npx meta docs # all three → ./docs (model) + ./docs/api + ./docs/requirements.*
117159
npx meta docs --model # model surface only
118160
npx meta docs --api # api surface only
161+
npx meta docs --requirements # requirement ledger only
119162
npx meta docs --out ./site-docs # write under a different root
120163
```
121164

0 commit comments

Comments
 (0)