Codegen Add Component
Table of Contents
1. When to use this skill
When the user asks to create a new ORE Studio component — a new
project under projects/. Most domain components are split into
.api, .core, and .service parts; decide which parts are needed
before starting. See Component architecture for the split rules,
facet placement, and CMake dependency chain.
2. How to use this skill
Codegen is mandatory for all boilerplate. Do not hand-write CMakeLists or stub files.
Since PR #1014 the
component_overview.org per component is the single source of
truth for both humans and codegen — the standalone
*_component.json and *_component.org models are retired.
- Gather requirements: component short name, parts needed
(
.api,.core,.service, or a subset), one-line brief, longer description. Scaffold the per-part overview via compass. For each part (
.api,.core,.service) run:./projects/ores.compass/compass.sh add component \ --slug component_overview \ --parent-dir projects/ores.COMPONENT/PART/modeling \ --title "ores.COMPONENT.PART" \ --description "<one-liner ≤ 120 chars>" \ --brief "<short tagline>"
The scaffold includes the codegen-readable keywords (
#+name:,#+full_name:,#+brief:) automatically. Fill in the* Summaryand other sections per Component Documentation Guide.Run codegen against each overview to scaffold the C++ + CMake project. Each overview's
#+component_kind:frontmatter (api,core,service, or the defaultflat) selects the scaffolding variant. Two addresses are needed:ores.cmake.componentwrites theCMakeLists.txtfiles, andores.cppwrites the C++ presence. The C++ address is the technical space rather than one facet, because the opt-in scaffold below is a sibling ofores.cpp.component../projects/ores.codegen/codegen.sh generate \ --model projects/ores.COMPONENT/api/modeling/component_overview.org \ --address ores.cmake.component ./projects/ores.codegen/codegen.sh generate \ --model projects/ores.COMPONENT/api/modeling/component_overview.org \ --address ores.cpp
Repeat per part (
.api,.core,.service), each against its own overview file.The overview scaffold writes
:ores.cpp.scaffold.enabled: trueinto the:PROPERTIES:drawer, because a component with no models yet needs the first-generation scaffold: an umbrella header, a placeholder domain type with its implementation, and a placeholder Catch2 test, so that its targets link and its test runner passes before any real code exists. That scaffold lives inores.cpp.scaffold, which is#+default: disabled, so that one line is the whole opt-in and nothing else emits the placeholders.Remove the line, and the four files, when the component's first real model lands. While the line is present, every regeneration re-emits the placeholders, which is what the line asks for;
grep -rn 'ores.cpp.scaffold.enabled: true' projects/*/modeling/lists the components still carrying scaffolding.- (Optional) Add a group-level overview at
projects/ores.COMPONENT/modeling/component_overview.org. The group overview is navigation + group-level codegen scalars; the directory layoutprojects/ores.COMPONENT/{api,core,service}/is the composite declaration (no:subcomponents:keyword needed). - Register each part in
projects/CMakeLists.txtin dependency order (.api→.core→.service). - Add a PlantUML stub (
modeling/ores.COMPONENT.PART.puml) for each part — codegen does not yet produce this. See component-model-creator for the diagram conventions. - Build and verify the scaffold tests with cmake-runner, via
compass build(not rawcmake --build, so it takes the host-wide build lock — see How do I build the system?):./compass.sh build ores.COMPONENT.api.tests - Fill in the architecture sections of each overview using component-model-creator (Inputs, Outputs, Entry points, Dependencies, See also, and the PlantUML diagram).
3. Templates
The C++ scaffold runs via --address ores.cpp; the overview's
#+component_kind: frontmatter picks the variant. The CMake files run via
--address ores.cmake.component.
#+component_kind: |
What ores.cpp writes |
|---|---|
flat (default) |
Export macros and the Catch2 test main; with the opt-in, the umbrella header, domain/stub.hpp, src/domain/stub.cpp and tests/stub_tests.cpp |
api, core |
The same as flat |
service |
Export macros, the test main and the service application; with the opt-in, the umbrella header and tests/stub_tests.cpp |
All four kinds consume the same model type component, read
from a component_overview.org via load_org_component_overview_model.
Full template list is in ORE Studio Codegen§"Profile catalogue".
The codegen-side scaffold flow is exercised by
projects/ores.codegen/tests/component_scaffold/verify.py — two
fixture components (flat + composite) plus prior-art checks
against ores.nats (flat) and ores.controller (composite
group + 3 subs).
4. Reference
- Component architecture — split rules, facet placement, CMake dep chain.
- ORE Studio Codegen — model schema, physical-space graph,
codegen.shusage. - component-model-creator — write the architecture docs once scaffold is working.
- cmake-runner — build and test commands.
5. Recipes
- How do I create a component overview? — the overview every new component needs.