A tasks API whose model, store, lifecycle rules, service and HTTP routes are all generated by
cargo meta gen from one file, metaobjects/meta.app.yaml. The
hand-written part is app/src/lib.rs: who the caller is, what they may do, and
the table. It is the Rust port's stand-in estate: the rust lane checks that the committed
generated/ crates are what gen writes today and runs the app's test over
HTTP.
One entity, Task, stored in tasks, with a status lifecycle: todo, doing and done, and
three transitions, start, finish and reopen (which is public). title and status can be
filtered on, and title sorted by. That is all the generators need:
| Crate | Generator | What it holds |
|---|---|---|
tasks |
entity |
Task, its create and patch bodies and validate() |
tasks_rules |
rules-names |
the lifecycle's states and transitions, and the permissions tasks.Task.start and tasks.Task.finish |
tasks_store |
repository |
list, count, get, create, update, delete and the guarded update, on sqlx |
tasks_service |
service |
each write in one transaction, with the rules checked in ADR-0066's order |
tasks_http |
service-routes |
the axum routes over the service |
meta_* |
the same | the shared code each tier uses, written into the project as source |
metaobjects.config.json lists those six. service-routes is opt-in: cargo meta init --transport
writes it into the list, and a plain cargo meta init leaves it out.
From a checkout, with cargo-meta installed from server/rust/metaobjects-cli:
cargo meta gen # rewrites nothing: generated/ is already current
cargo test # the HTTP test, on an in-memory SQLite database
cargo run -p tasks_app # serves http://127.0.0.1:3000/api/taskscurl -s -XPOST localhost:3000/api/tasks -H 'x-user: ada' -H 'content-type: application/json' \
-d '{"title": "Write the docs"}'
curl -s -XPOST localhost:3000/api/tasks/1/start -H 'x-user: ada'
curl -s -XPOST localhost:3000/api/tasks/1/finish -H 'x-user: grace' -H 'x-role: lead'
curl -s 'localhost:3000/api/tasks?filter[status][eq]=done&withCount=true'finish without x-role: lead answers 403 forbidden, a second start 409
invalid_transition, and a PATCH naming status 409 state_managed: the service makes those
checks, and the routes only carry them to the wire.
Change the model and run cargo meta gen again; cargo meta verify fails while generated/ is
behind it. The table is the app's own (SCHEMA in app/src/lib.rs): migrations run in the
project's own tool, or the Node meta migrate reference helper. See
the Rust port page.