Skip to content

YAML behavior files, ivpico_bhv, and inline behaviors - #26

Open
tsaubergine wants to merge 1 commit into
mainfrom
add-yaml-behaviors
Open

tsaubergine wants to merge 1 commit into
mainfrom
add-yaml-behaviors

Conversation

@tsaubergine

@tsaubergine tsaubergine commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Implements Y1–Y6 of the YAML behavior files plan, with yaml-cpp optional. Behaviors can now come from .bhv.yml files, checked against a JSON Schema, or inline in the helm configuration, as well as from .bhv files. .bhv stays the reference: everything else is converted to .bhv text for MOOS-IvP's unchanged Populator.

Changes

  • ivp.interface.BehaviorSet (behaviors.proto) holds what one behavior file does:

    • initialize, deferred or not;
    • modes;
    • behaviors, with the parameters every behavior takes as typed fields and the behavior's own parameters as an ordered list.

    Values keep their source text. HelmConfig.behaviors takes sets inline.

  • The helm (behavior_file.{h,cpp}):

    • .bhv reader: ports the Populator's line handling, including its brace splitting, \ continuations and set blocks.
    • .bhv writer: reports values .bhv can't hold, such as //, a newline or a brace where the Populator splits.
    • With any YAML or inline behaviors, every behavior file (in the order given) and then the inline sets go into one temporary file. The Populator's warnings are rewritten to point at the original file:line:column, or at the path in the configuration (behaviors[0].behavior[1].param[2]).
    • Configs with only .bhv files keep pHelmIvP's path, with files read in sorted order.
  • YAML (behavior_yaml.cpp, only with yaml-cpp):

    • read with yaml-cpp, so parameter order and repeats are kept and scalars are read as written (3.10, on, 0x1);
    • every error names its line and column;
    • merges (<<: *name) and top-level x- keys allow shared settings.
  • yaml-cpp is optional: the enable_yaml option is ON when yaml-cpp is found and defines HAS_YAML. Without it, YAML files are a config warning and the tool says so; inline behaviors still work.

  • ivpico_bhv:

    • convert: YAML to .bhv;
    • import: .bhv to YAML, with a yaml-language-server schema line;
    • check: builds the behaviors and reports each problem where it was written;
    • schema: prints the JSON Schema. share/ivpico/bhv.schema.json is generated from BehaviorSet, committed and installed.
  • The alpha launch uses alpha.bhv.yml.

  • init.sh installs libyaml-cpp-dev, plus python3-jsonschema and python3-yaml for the schema test.

  • README: outline of a "Behavior files" section, for you to fill in.

Testing

  • behavior_file unit tests:
    • every .bhv construct, and lines the Populator rejects;
    • writer errors and warning relocation;
    • YAML: constructs, verbatim scalars, errors at their line and column, merges;
    • the helm with inline, YAML and mixed behaviors;
    • every fixture .bhv round-trips through .bhv and YAML to the same BehaviorSet.
  • replay_<fixture>_yaml: all 19 fixtures replay with pass conditions identical to the originals, with their behaviors loaded from YAML converted from their .bhv.
  • bhv_schema: the committed schema matches the generated one.
  • bhv_schema_examples: every imported fixture and alpha.bhv.yml validate, and seven files the reader rejects fail.
  • closed_loop_s1_alpha_yaml and closed_loop_s1_alpha_inline: the full s1_alpha mission, including stopping at the return point.
  • All 61 tests locally, and all 40 with -Denable_yaml=OFF. CI now also builds without yaml-cpp on one job.
  • CI, including the build without yaml-cpp.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VLcYK4e29B5FiPbDDJy5fp

Behaviors can now come from .bhv.yml files, checked against a JSON
Schema, or inline in HelmConfig.behaviors, as well as from .bhv files.

- behaviors.proto: ivp.interface.BehaviorSet, what one behavior file
  holds. The parameters every behavior takes are typed fields; a
  behavior's own parameters are an ordered list. Values keep their
  source text.
- The helm converts YAML and inline behaviors to .bhv text for the
  unchanged Populator. With any of them, every behavior file (in the
  order given) and then the inline sets go into one temporary file, and
  the Populator's warnings are rewritten to the original file, line and
  column, or the path in the configuration. Configs with only .bhv files
  keep pHelmIvP's path.
- yaml-cpp is optional (enable_yaml, on when found; HAS_YAML). YAML is
  read with it so parameter order and repeats are kept, scalars are read
  as written, and every error names its line and column. Merges (<<) and
  x- keys allow shared settings.
- ivpico_bhv: convert (YAML to .bhv), import (.bhv to YAML), check
  (builds the behaviors, reporting each problem where it was written)
  and schema. share/ivpico/bhv.schema.json is generated from the
  BehaviorSet message, committed and installed.
- The alpha launch uses alpha.bhv.yml.

Tests: unit tests of the reader, writers and the helm; every fixture
.bhv round-trips through .bhv and YAML; replay_<fixture>_yaml replays
every fixture from YAML; the committed schema must match the generated
one, and imported fixtures and alpha.bhv.yml must validate against it;
s1_alpha closed loops from alpha.bhv.yml and from inline behaviors. CI
also builds without yaml-cpp on one job.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VLcYK4e29B5FiPbDDJy5fp
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.

2 participants