Skip to content

NoDL Composition - new Node schema with base, main, and mixins#86

Draft
emersonknapp wants to merge 6 commits into
mainfrom
emerson/composition
Draft

NoDL Composition - new Node schema with base, main, and mixins#86
emersonknapp wants to merge 6 commits into
mainfrom
emerson/composition

Conversation

@emersonknapp

Copy link
Copy Markdown
Member

Replaces #80

@read-the-docs-community

read-the-docs-community Bot commented Jun 10, 2026

Copy link
Copy Markdown

Documentation build overview

📚 nodl | 🛠️ Build #33125749 | 📁 Comparing ed28523 against latest (9bd4a26)

  🔍 Preview build  

3 files changed
± concepts.html
± index.html
± schema.html

emerson and others added 2 commits June 10, 2026 16:26
Schema (nodl_schema/schemas/nodl.schema.yaml):
  Top-level 'base' (enum of node / lifecycle_node) declares the
  built-in node interface to inherit.
  Top-level 'fragments' (array of fragment_ref) declares additional
  fragment interfaces to compose in, by relative path or 'nodl://pkg/name'.
  fragment_ref definition has required 'ref' and optional 'name' (label
  used for merge ordering and documentation).
  Generated models pick these up automatically; FragmentRef and the
  Base enum are added to NodlDocument.

nodl_schema.validator:
  validate_fragment(data) runs the regular schema validation, then
  rejects the presence of top-level 'base' or 'fragments'.
  Fragments are flat ingredients; nested composition is intentionally
  disallowed in v2 and can be lifted later without a schema change.
  load_fragment(source) wraps load_nodl with this stricter check.
  python -m nodl_schema gains a --fragment flag for build-time hooks.

nodl_schema.resolve:
  resolve(doc, source_path=None) returns a LayeredDocument carrying
  the resolved base, the resolved fragments (by label), and the main
  document.
  LayeredDocument.merged() flattens into a single NodlDocument with
  later layers winning on duplicate names; order is base -> fragments
  (insertion order) -> main.
  Every load path goes through load_fragment, so a fragment that
  declares its own base or fragments is rejected at resolve time with
  a clear error.

Bundled fragments:
  node.nodl.yaml: declares use_sim_time.
  lifecycle_node.nodl.yaml: adds the standard transition services and
  the transition_event publisher on top of the node fragment.

ament_nodl_register_fragment:
  Sibling of register_node, following the same install RENAME pattern,
  rosidl-style docstring, and "NoDL file" wording.
  Build-time validation via add_custom_command/target that runs
  'python -m nodl_schema --fragment <file>' against the source.
  The stamp target is ALL, so install won't proceed without it.

Tests:
  test_ament_nodl gains register_fragment tests (5 cases) covering
  default and explicit PACKAGE, byte-for-byte resource vs source,
  and source-file install layout.
  nodl_schema/test/test_resolve.py covers no-base, both bases,
  relative fragment resolution (success / missing / no source path),
  layer precedence (main > fragments > base), and explicit rejection
  of a fragment that declares its own base or fragments.
  nodl_schema/test/test_schema.py: the previously inverted
  base/fragments rejection tests become positive accept tests, plus
  'unknown base rejected' and 'fragment_ref missing ref rejected'
  negative cases.
  nodl_schema/test/test_validator_cli.py: adds --fragment cases for
  valid fragments, rejection of base/fragments at the top level, and
  combined invalid-schema + fragment cases.

Smoke-tested end-to-end by appending 'base: node' to a fragment fixture:
the build fails at the validate_fragment target with the expected
error and restoring brings it back green.

Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
Signed-off-by: Emerson Knapp <emerson@polymathrobotics.com>
Signed-off-by: Emerson Knapp <emerson@polymathrobotics.com>
@emersonknapp emersonknapp force-pushed the emerson/composition branch from d4a32c7 to b58cddb Compare June 10, 2026 23:26
@emersonknapp emersonknapp marked this pull request as draft June 11, 2026 04:50
emersonknapp and others added 4 commits June 10, 2026 21:58
Signed-off-by: Emerson Knapp <emerson@polymathrobotics.com>
Signed-off-by: Emerson Knapp <emerson@polymathrobotics.com>
Signed-off-by: Emerson Knapp <emerson@polymathrobotics.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant