Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f36e344
test(python): pin router, names and filter-allowlist output byte for …
dmealing Nov 20, 2026
d198291
feat(python): code writer, layout check and first generators on it (W…
dmealing Nov 21, 2026
ee6e3cb
fix(python): accept every expression function and the cast node at lo…
dmealing Nov 21, 2026
93d2292
feat(python): per-generator packages, entities and options in metaobj…
dmealing Nov 21, 2026
576db3a
fix(python): keep the selection wrapper out of the generator census (…
dmealing Nov 21, 2026
1aed790
feat(python): split ObjectManager into abstract ObjectManager and Obj…
dmealing Nov 21, 2026
08ceb3d
feat(python): shared-model publisher, all 15 shared-model cases (D6)
dmealing Nov 21, 2026
22aaab6
test(python): record the orphan write in the per-package hash manifes…
dmealing Nov 21, 2026
ed37454
no-mistakes(review): Refuse repeated configured generators and empty …
dmealing Nov 21, 2026
20e626c
no-mistakes(review): Emit report export columns as a list
dmealing Nov 21, 2026
19525eb
no-mistakes(test): Refuse per-entity gaps in required generators
dmealing Nov 21, 2026
b913db7
no-mistakes(document): Fix stale Python lane docs
dmealing Nov 21, 2026
115b113
no-mistakes(document): Fix stale Python ledger notes and view scope
dmealing Nov 21, 2026
f1ed73d
test(python): pin router, names and filter-allowlist output byte for …
dmealing Nov 20, 2026
cb003e0
feat(python): code writer, layout check and first generators on it (W…
dmealing Nov 21, 2026
5b21a1c
fix(python): accept every expression function and the cast node at lo…
dmealing Nov 21, 2026
3290841
feat(python): per-generator packages, entities and options in metaobj…
dmealing Nov 21, 2026
ff045a5
fix(python): keep the selection wrapper out of the generator census (…
dmealing Nov 21, 2026
541c47f
feat(python): split ObjectManager into abstract ObjectManager and Obj…
dmealing Nov 21, 2026
371a0f3
feat(python): shared-model publisher, all 15 shared-model cases (D6)
dmealing Nov 21, 2026
5ff8592
test(python): record the orphan write in the per-package hash manifes…
dmealing Nov 21, 2026
0ce7f55
no-mistakes(review): Refuse repeated configured generators and empty …
dmealing Nov 21, 2026
17aaeab
no-mistakes(review): Emit report export columns as a list
dmealing Nov 21, 2026
28f91f6
no-mistakes(test): Refuse per-entity gaps in required generators
dmealing Nov 21, 2026
ebb4394
no-mistakes(document): Fix stale Python lane docs
dmealing Nov 21, 2026
c401965
no-mistakes(document): Fix stale Python ledger notes and view scope
dmealing Nov 21, 2026
531b5db
fix(python): escape a trailing double quote in a one-line docstring; …
dmealing Nov 21, 2026
f889b4d
merge: keep the rebased tree, descend from the pre-rebase gate head
dmealing Nov 21, 2026
6f54e14
no-mistakes(review): Revert TS runner edit; fix stale ObjectManagerDb…
dmealing Nov 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,56 @@ Each item below is described in full under Security, Added, Changed or Fixed; th
with a written, shrink-only allowlist) now holds Java generator source to it. No shipped Java
generator uses the writer yet, so generated output does not change in this release.

- **A code writer for Python generators: `CodeWriter` and `PyWriter` in `metaobjects.codegen.writer`**
(ADR-0063). The Python port of the writer contract in `spec/code-writer.md`: the language-neutral
core (lines, blocks, blank-line requests, snippets, fit-or-break lists), run against the shared
`core` cases of `fixtures/writer-conformance/`, plus a Python dialect with its own eleven cases (imports
collected and sorted as `__future__`, absolute, relative; docstrings; suites that end by dedenting;
`gap()` for the two blank lines between top-level definitions). It is on the engine surface an
ejected generator may import (`eject.engineSurface.python.engine`). A layout check
(`tests/codegen/test_layout_ratchet.py`) parses generator source with `ast` and fails on a string
holding a line break, a string that starts with indentation, a join on a newline or an indentation
built by repeating a space; every file that still types its layout is on an allowlist that only
shrinks. The `output-prompt`, `report-export` and `filter-allowlist` generators now write through it
and no longer call `ruff`; the others convert one at a time, and `ruff_format` stays exported for
owned generators that call it.

- **Python publishes a shared model (FR-023).** A `shared-model` generator, wired in
`metaobjects.config.yaml` like any other (`metaobjects gen --list` names its options), writes
`<name>.metaobjects.json` and `metaobjects.pkg.json` for a consumer's `deps sync`: `name` and
`include` (required), `exclude`, `requirements`, `files` (relative to the project root; default
every metadata file of the project) and `version` (default: the nearest `pyproject.toml` or
`package.json` version, a declared input of the run). It was TypeScript, Java, Kotlin and C#
only, so a Python project ran a TypeScript generator for it. The bytes are the other ports': the
Python test runs all 15 cases of `fixtures/shared-model-conformance/` (nine publish, six
refusal), where it ran only the nine documents before. The engine is `metaobjects.shared_model`
(`build_shared_model`, `render_shared_model_files`, `SharedModelError` carrying the refusal
reason). A `generators` entry's `options` also gain a list kind, for `include`, `exclude` and
`files`.
- **Python: the `ObjectManager` splits into an abstract `ObjectManager` and a concrete
`ObjectManagerDb` (breaking).** `ObjectManager(root, driver)` no longer constructs: it raises a
`TypeError` naming `ObjectManagerDb(root, driver)`, and there is no shim. `ObjectManager` is
now the store-neutral contract (the Java `ObjectManager` / `ObjectManagerDB` shape) that
generated and hand-written code can be typed against; `ObjectManagerDb` is the DB-API
implementation on Postgres, SQLite and MySQL, with the same SQL and the same rows as before.
New with the split: `with om.transaction():` (every write in the block commits together or
rolls back together; a nested block joins the outer one), persistence listeners
(`om.add_listener(PersistenceListener)`, before and after each create, update and delete), and
`metaobjects.runtime.values`, the write and read value codecs as a public module. The drivers
(`DbApiDriver`, `PostgresDriver`, `SqliteDriver`, `MySqlDriver`) now live in
`metaobjects.runtime.drivers` and keep their `metaobjects.runtime` exports. Upgrade note:
[docs/features/migrations/python-object-manager-split.md](docs/features/migrations/python-object-manager-split.md).
- **Python: per-generator package and entity selection and generator options in
`metaobjects.config.yaml`.** A `generators` entry written as a mapping now takes `packages`,
`entities` and `options` beside `name` and `handEdits`. `packages` and `entities` limit that one
generator to part of its target; `options` hands the generator its own settings, in camelCase,
as snake_case keyword arguments. They work for a packaged generator (`report-export` takes
`maxRows`, `xmlNulls` and `csvBom`; `routes` takes `reportMaxRows`; `metaobjects gen --list` names
them) and for a team's own `module:symbol` one, whose factory or class receives them (or, if it
takes the build context, reads `ctx.options`). A package or entity the target does not hold, an
option a generator does not take, and options on a generator instance are refused with a message
that lists what is accepted, never ignored. `metaobjects-config.schema.json` carries the keys.

- **Select objects to regenerate in every port.** C# `dotnet meta gen --entities A,B` (and
`verify --codegen --entities`) and, for Java and Kotlin, `mvn metaobjects:generate
-Dmeta.entities=A,B` regenerate only the named objects' files, like TypeScript's
Expand Down Expand Up @@ -1897,6 +1947,15 @@ Each item below is described in full under Security, Added, Changed or Fixed; th
is kept: the services wrap it. The `.csproj` the name is read from is an input of `dotnet meta
gen`'s skip key (ADR-0064), so renaming the assembly renders again.

- **Python: the `output-prompt`, `report-export` and `filter-allowlist` generators lay out their own
output** (ADR-0063). The bytes no longer depend on whether `ruff` is installed or on its version.
The files read the same, with these differences: a module docstring closes on its own line, a
broken call or set literal ends with a trailing comma, `import x` lines come before `from x import`
lines in a section, and a literal that fits 88 columns stays on one line. If you subclass
`FilterAllowlistGenerator`, `_emit_constants` now writes onto a `PyWriter` it is handed instead of
returning source lines; an override of `OutputPromptGenerator._emit_format_spec` may return text or
a writer piece.

### Deprecated

- **C#: `ValueObjectNames.Names(root)`.** A value object is never renamed, so it now returns the
Expand All @@ -1905,6 +1964,16 @@ Each item below is described in full under Security, Added, Changed or Fixed; th

### Fixed

- **Python: an `origin.computed` `@expr` and a validator `@condition` accept every expression
function and the `cast` node.** The Python loader knew only `coalesce`, so a projection that used
`lower`, `greatest`, `splitPart`, `concat`, `nullif`, `length` or `{ cast, as }` was refused with
`ERR_UNKNOWN_EXPR_NODE` while the TypeScript, C#, Java and Kotlin loaders accepted it. It now
validates the same fifteen functions (arity, parameter kinds, result type), checks a cast
against the same table of what can become what (an enum stored as an integer casts to `int`, an
object never casts, a boolean casts only to `int`), and refuses in a CHECK `@condition` anything
only a view can hold (a cast, a function other than `coalesce`, a dotted path). Python-written
models are unaffected unless they used these nodes, which never loaded.

- **A credential is never filterable or sortable, in every port.** A field that declares a
`view.password` and that a model also marked `@filterable` or `@sortable` was on the generated
filter and sort allowlists, so a client could learn its value by probing (`filter[pinHash][eq]=...`,
Expand Down
25 changes: 16 additions & 9 deletions agent-context/skills/metaobjects-runtime-ui/references/python.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,40 @@
# Python server runtime

The Python runtime tier is the **`metaobjects.runtime.ObjectManager`** — a
The Python runtime tier is **`metaobjects.runtime.ObjectManagerDb`** — a
metadata-driven query/CRUD engine that reads the same metadata at runtime and drives
persistence with no per-entity ORM boilerplate. It is the cross-port analog of Java's
OMDB: a method-based API (`find_by_id` / `find_many` / `count` / `create` / `update` /
persistence with no per-entity ORM boilerplate. It is the DB-API implementation of the
abstract `ObjectManager` contract and the cross-port analog of Java's `ObjectManagerDB`
(OMDB): a method-based API (`find_by_id` / `find_many` / `count` / `create` / `update` /
`delete` / `relate`) that compiles a Filter dict to parameterized SQL and runs it via a
pluggable driver. It is **pure data-access** (CRUD / query / codec); schema is owned by
the Node `meta` migration tool, not the runtime.

## Contents
- Construct an `ObjectManager`
- Construct an `ObjectManagerDb`
- CRUD + query
- Return-type contract
- Serving the REST contract
- Physical names in your repository implementation

## Construct an `ObjectManager`
## Construct an `ObjectManagerDb`

`ObjectManager(root, driver)` takes a loaded metadata `root` plus a `PostgresDriver`
wrapping any DB-API 2 connection (pg8000 / psycopg):
`ObjectManagerDb(root, driver)` takes a loaded metadata `root` plus a driver
(`PostgresDriver`, `SqliteDriver` or `MySqlDriver`) wrapping any DB-API 2 connection
(pg8000 / psycopg for Postgres). `ObjectManager` is the abstract contract: constructing it
raises a `TypeError` naming `ObjectManagerDb`, so annotate hand-written code that only calls
the methods with `ObjectManager` and construct `ObjectManagerDb`:

```python
import pg8000
from metaobjects import load_directory
from metaobjects.runtime import ObjectManager, PostgresDriver
from metaobjects.runtime import ObjectManagerDb, PostgresDriver

result = load_directory("metaobjects") # same canonical JSON every port reads
conn = pg8000.connect(...) # any DB-API 2 connection
om = ObjectManager(result.root, PostgresDriver(conn))
om = ObjectManagerDb(result.root, PostgresDriver(conn))

with om.transaction(): # one commit for every write in the block
om.create("Author", {"name": "Ada"}) # a raise inside rolls all of it back
```

## CRUD + query
Expand Down
9 changes: 4 additions & 5 deletions docs/CONFORMANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ regenerate with `ls -d fixtures/<corpus>/*/ | wc -l` for directory-shaped corpor
| [`fixtures/source-resolution-conformance/`](../fixtures/source-resolution-conformance/) | 28 cases | ✓ (reference implementation) | ✓ | inherits via Java | ✓ | ✓ |
| [`fixtures/scope-conformance/`](../fixtures/scope-conformance/) | 10 cases | ✓ (reference implementation) | ✓ | inherits via Java | ✓ | ✓ |
| [`fixtures/dependency-conformance/`](../fixtures/dependency-conformance/) | 47 cases (36 resolution, 7 of them with a ledger arm, + 11 check) + 32 transport cases | ✓ (reference implementation; all four arms) | ✓ (resolution arm, all 36, ledger included; check arm, all 11) | inherits via Java | ✓ (resolution arm, all 36, ledger included; check arm, all 11, as `verify --deps`) | ✓ (resolution arm, all 36 identically, ledger included; check arm, all 11, as `deps check` and `verify --deps`; the transport arm is Node-only) |
| [`fixtures/shared-model-conformance/`](../fixtures/shared-model-conformance/) | 15 cases (9 publish + 6 refusal) | ✓ (reference implementation) | ✓ (all 15; `SharedModelConformanceTest`) | inherits via Java (`KotlinSharedModelGeneratorTest` pins the generator) | ✓ (all 15; `SharedModelConformanceTests`) | ✓ (serializer arm: the 9 publish cases' document bytes; no publisher) |
| [`fixtures/shared-model-conformance/`](../fixtures/shared-model-conformance/) | 15 cases (9 publish + 6 refusal) | ✓ (reference implementation) | ✓ (all 15; `SharedModelConformanceTest`) | inherits via Java (`KotlinSharedModelGeneratorTest` pins the generator) | ✓ (all 15; `SharedModelConformanceTests`) | ✓ (all 15; `test_shared_model_conformance.py`) |
| [`fixtures/agent-context-conformance/`](../fixtures/agent-context-conformance/) | 5 | ✓ (the emitter is TS-owned) | — | — | — | — |
| [`fixtures/metamodel-docs/`](../fixtures/metamodel-docs/) | 1 | ✓ (docs emit is TS-owned) | — | — | — | — |
| [`fixtures/fmt-conformance/`](../fixtures/fmt-conformance/) (#304 — `meta fmt`) | 13 | ✓ (reference) | ✓ | inherits via Java | ✓ | ✓ |
Expand All @@ -66,7 +66,7 @@ regenerate with `ls -d fixtures/<corpus>/*/ | wc -l` for directory-shaped corpor
| [`fixtures/codegen-skip-conformance/`](../fixtures/codegen-skip-conformance/) (when `gen` may skip and what a local `verify --codegen` may answer, ADR-0064) | one case table in `cases.json`, plus the manifest layout vectors in `manifests.json` (ADR-0064 Amendment 1) | ✓ | ✓ | ✓ (through the Java runner) | ✓ | ✓ |
| [`fixtures/codegen-noop/`](../fixtures/codegen-noop/) (vocabulary with no lowering yet: FR-044 reporting, what is lowered and what stays inert; ADR-0066 business rules, inert everywhere) | 2 model pairs (`reporting/` and `rules/`, each `with` vs `without`) | ✓ (codegen + migrate) | ✓ | ✓ | ✓ | ✓ |
| [`fixtures/cube-model/`](../fixtures/cube-model/) (FR-044 Plan 4 — the `cube-model` generator's golden Cube files, plus the canonical model's golden) | 46 cases (36 trees + 10 errors) + 1 canonical golden | ✓ (the exporter is TypeScript-only, spec R6; its `cube` lane also loads the files into a real Cube) | — | — | — | — |
| [`fixtures/writer-conformance/`](../fixtures/writer-conformance/) (ADR-0063 — the code writer generators write through) | 50 cases (31 core + 10 TypeScript + 9 Java) | ✓ (the first writer; core and TypeScript dialect) | ✓ (core and Java dialect; `JavaWriter` in `codegen-base`) | — (writer not built yet) | — (writer not built yet) | — (writer not built yet) |
| [`fixtures/writer-conformance/`](../fixtures/writer-conformance/) (ADR-0063 — the code writer generators write through) | 61 cases (31 core + 10 TypeScript + 9 Java + 11 Python) | ✓ (the first writer; core and TypeScript dialect) | ✓ (core and Java dialect; `JavaWriter` in `codegen-base`) | — (writer not built yet) | — (writer not built yet) | ✓ (core and Python dialect) |
| [`fixtures/contract-conformance/`](../fixtures/contract-conformance/) (FR-022 — the `contract-schema` and `openapi` generators' golden trees and refusals) | 19 cases (14 trees + 5 errors) | ✓ (one neutral engine, ADR-0034 Amendment 10; the generated API lanes also hold real traffic to the documents) | — | — | — | — |
| [`fixtures/explorer-conformance/`](../fixtures/explorer-conformance/) (the `explorer.json` data spine: `meta export --effective` + `meta verify --format json` + the generated-file manifest in, one explorer document out) | 1 case (`shop`) | ✓ (the builder is TypeScript, and reads only port-neutral inputs) | — | — | — | — |

Expand Down Expand Up @@ -668,9 +668,8 @@ unless `requirements` is set, and the order of `files` does not change the bytes
the manifest records the toolchain's `metamodelVersion`, so they do not move with it.

**TypeScript runs all 15**, in `codegen-ts/test/shared-model-conformance.test.ts`. **Python runs
the serializer arm**: for each publish case it loads `files`, takes the nodes the pinned manifest
lists, and `serialize_shared_document` must reproduce the artifact byte for byte (and the sha256
the manifest records). Python has no publisher, so selection and the refusals are TypeScript's.
all 15**, in `tests/conformance/test_shared_model_conformance.py`, against `metaobjects.shared_model`,
the engine its `shared-model` generator calls.
**Java runs all 15**, in `metadata`'s `SharedModelConformanceTest` against the `SharedModel` engine
the `shared-model` generator calls; **Kotlin** runs through that same engine and Maven goals and adds
only `KotlinSharedModelGeneratorTest`. **C# runs all 15**, in `SharedModelConformanceTests`.
Expand Down
23 changes: 22 additions & 1 deletion docs/features/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,13 @@ targets:
# or an owned copy as "module:symbol". Nothing runs that is not listed.
admin:
outDir: src/generated/admin
generators: [entity]
generators:
- entity
- name: filter-allowlist # an entry may be a mapping: a generator limited to part of the target
packages: [shop::catalog]
entities: [Book]
- name: report-export # and given its own settings
options: {maxRows: 5000, xmlNulls: nil, csvBom: true}
entities: [Author, Book] # optional allowlist; omit = every entity
docs:
outDir: docs/python # a directory of its own: another port's pages here read as drift
Expand All @@ -489,6 +495,21 @@ targets:
`--target <name>` scopes the run to a single target; `--generators <names>` narrows it to
the declared entries named (an owned entry matches its registry name too) and refuses a
name no target declares. A target whose `generators` is empty writes nothing and says so.
- **A `generators` entry may be a mapping** `{name, handEdits, packages, entities, options}`:
- `packages` (metadata packages such as `shop::catalog`) and `entities` (short object names)
limit that one generator to part of the target, inside the target's own `entities`. The
selection narrows what the generator is given, so a whole-model file it writes (shared enums,
a report writer) is built from the selected objects only. A name the target holds no object
for is refused, not skipped: a typo there would otherwise drop the generator's output and
the run would still report success.
- `options` are the generator's own settings, keyed in the camelCase every key in this file
uses (`maxRows`) and handed to the generator as snake_case keyword arguments (`max_rows`).
`metaobjects gen --list` names the options each packaged generator takes (`report-export`:
`maxRows`, `xmlNulls`, `csvBom`; `routes`: `reportMaxRows`); an option a generator does not
take is refused and the message lists the ones it does. A team's own generator (`module:symbol`)
gets them the same way: as keyword arguments to its factory or class (a `**options` factory
takes any), or, for a factory that takes the build context, as `ctx.options`, exactly as
written. A factory that takes none, and a ready-made generator instance, refuse them.
- **`metaobjects verify --codegen`** — also run by bare `verify`, which adds `--templates`
(see above) — regenerates the same list in memory (the exact `gen`
pipeline, including the cross-target duplicate-output-path guard) and diffs each **unique
Expand Down
6 changes: 3 additions & 3 deletions docs/features/entities.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public partial class AppDbContext : DbContext
`metaobjects.codegen` emits one Pydantic `BaseModel` per entity (not a `@dataclass`), with a
`<Name>Create` and a `<Name>Patch` input model beside it, plus a shipped
FastAPI `APIRouter` (`router_generator`, FR-008 §2.3) and a shipped
`ObjectManager` runtime (`metaobjects.runtime.object_manager`) for CRUD
`ObjectManagerDb` runtime (`metaobjects.runtime.object_manager_db`, the DB-API implementation of the abstract `ObjectManager`) for CRUD
against the same metadata.

```python
Expand Down Expand Up @@ -345,9 +345,9 @@ class AuthorPatch(BaseModel):
```

```python
from metaobjects.runtime.object_manager import ObjectManager
from metaobjects.runtime import ObjectManagerDb

om = ObjectManager(root, driver) # driver wraps a DB-API 2 connection
om = ObjectManagerDb(root, driver) # driver wraps a DB-API 2 connection; ObjectManager is the abstract contract
row = om.create("Author", {"name": "Ada", "bio": None})
found = om.find_by_id("Author", row["id"])
```
Expand Down
Loading
Loading