Code Add Domain Type
Table of Contents
When to use this skill
When you need to add a new domain type to an ORE Studio component with JSON I/O, table I/O, a test data generator, and repository CRUD support. This is the mandatory first step before any exposure layer (SQL schema, HTTP, CLI, shell, Wt, Qt) can be built. See the Entity lifecycle overview for the full layer ordering.
How to use this skill
Codegen is the primary path for a persisted, data-carrying entity
(one with SQL storage, and usually a UI). Manual creation is
appropriate — not a last resort — for a behaviour-heavy value type
(parsing, comparison operators, computed methods) with no persistence
or generated UI: none of codegen's entity-model types generate that
shape, they generate flat data-carrying structs plus persistence/UI
layers. See e.g. ores.analytics.quant's own domain types
(currency_id, ccy_pair, …), which are hand-authored for exactly
this reason — no codegen banner, not listed in
compass codegen entity list. Justify the choice in the file header
either way.
- Create an org-mode entity model under the target component's
modeling/directory (co-located org models — see thecomponent_catalogue.org'smodeling_dircolumn), following theores.codegen.entity(full entity: C++ + SQL + Qt),ores.codegen.lookup_entity(SQL-only reference table),ores.codegen.field_group(flat C++ struct fragment composed into a parent entity),ores.codegen.table, orores.codegen.junctionschema — see Codegen input org-file schema reference for the authoritative frontmatter keywords and section hierarchy per type. (The legacy*_domain_entity.json=/=models/{component}/format this step used to reference no longer exists in the repo — org-mode entity models superseded it.) Scaffold viacompass add --type entity_org ...(orfield_group=/=table=/=junction=/ =lookup_entityas appropriate) per How do I add a doc with compass?, then fill in the sections by hand. - Generate the C++ artefacts via compass, not the generator script
directly:
compass codegen generate --model <path/to/model.org> --address ores.cpp(compass codegen entity generate <entity>regenerates an already-modelled entity's full supported set;compass codegen entity list/show/diffinspect what exists and whether it's stale). - Build and verify: use cmake-runner to confirm the component library compiles cleanly.
- Raise PRs at phase boundaries — Phase 1: domain + I/O; Phase 2:
generator; Phase 3: repository; Phase 4: tests + diagrams. Use
feature-branch-managerto transition between branches andpr-managerto open each PR. - Update diagrams after Phase 4: plantuml-class-modeler for the class diagram; plantuml-er-modeler for the ER diagram.
If codegen cannot express the pattern, extend the Mustache templates
in library/templates/ first, then regenerate. See
ORE Studio Codegen§"Profile catalogue" for what each profile generates
and which library it uses.
Recipes
- Entity lifecycle — layer ordering, type mappings, service naming.
Reference
- ORE Studio Codegen — model schema, profiles, and template catalogue.
- Entity lifecycle — canonical type mappings and service method naming.
- cmake-runner — build and test commands.
- unit-test-writer — writing Catch2 tests for the new domain type.
Templates
Runs via --address ores.cpp (combines domain · generator · repository ·
service · protocol). Full output paths are in
Entity lifecycle§"Complete entity file checklist".
| Sub-address | Key templates |
|---|---|
--address ores.cpp.domain |
cpp_domain_type_class.hpp.mustache (+ 6) |
--address ores.cpp.generator |
cpp_domain_type_generator.hpp.mustache (+ 1) |
--address ores.cpp.repository |
cpp_domain_type_entity.hpp.mustache (+ 5) |
--address ores.cpp.service |
cpp_service.hpp.mustache (+ 1) |
--address ores.cpp.protocol |
cpp_protocol.hpp.mustache |
Read the template directly for the authoritative implementation — do not reproduce it here.