Skip to content

Fail Modelica generation when paths.boblib is not the BobLib the builds load - #152

Merged
raorjun merged 3 commits into
mainfrom
fix/generator-boblib-root
Oct 29, 2026
Merged

raorjun merged 3 commits into
mainfrom
fix/generator-boblib-root

Conversation

@raorjun

@raorjun raorjun commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

What

A stale paths.boblib made the generator write a stray record tree and report success. The builds load only engines/boblib/BobLib (line 4 of build_vehicle_sim.mos and build_four_post_sim.mos), so the executed car was not the YAML car. The app build also caught the error and compiled anyway.

Changes

  • The planner requires paths.boblib to resolve to <root>/engines/boblib/BobLib with a package.mo. Otherwise it raises BobLibRootError before any write. The CLI exits 2.
  • The app build stops and returns 1 without starting OpenModelica.

How to check

New tests in tests/test_modelica_generator.py and tests/test_app_shell.py, including one that checks both .mos files load the generator's directory. Full suite at the top of the stack: 1150 passed, 39 skipped, 1 worktree-only failure (test_bobsim_sources_do_not_reference_legacy_boblib_generation_layout, git ls-files in a worktree).

Notes

Stack

1 of 7. Based on main.

Overlap

#151 edits the same import block and one test in tests/test_modelica_generator.py. The conflict is trivial: keep both.

A stale paths.boblib (for example lhre's old-layout value
_0_Utils/external/BobLib/BobLib) made the generator create a stray
record tree and report success. The build then compiled the untouched
engines/boblib records, so the executed car was not the YAML car.

The planner now requires paths.boblib to name a directory whose
package.mo declares package BobLib. It raises BobLibRootError before
any write. The error names the path, the resolution base and the fix.
generate_modelica_stack also refuses to write a file that resolves
outside that package root. The CLI prints the error and exits 2.

Test fixtures that wrote into a bare tmp BobLib directory now create
a minimal package.mo.
The previous guard accepted any directory whose package.mo declared
package BobLib. An in-place submodule update from the old layout can
leave the old _0_Utils/external/BobLib/BobLib tree on disk. A vehicle
file that still named it passed the guard. The generator wrote records
into that tree and reported success. The builds load only
engines/boblib/BobLib (build_vehicle_sim.mos and build_four_post_sim.mos
line 4), so they compiled the untouched records.

The planner now requires paths.boblib to resolve to
<root>/engines/boblib/BobLib. It also requires that package.mo exists.
Otherwise it raises BobLibRootError before any write. The error names
both paths. A test checks that both .mos files load the same directory
as the generator constant, so the two cannot drift.

Test fixtures now place their BobLib package at engines/boblib/BobLib.
_run_modelica_build_action caught every exception from the stack status
call, logged "Build cache unavailable" and compiled fresh. A
BobLibRootError therefore did not stop the app build. The build then
compiled records that did not come from the vehicle file.

The action now catches BobLibRootError first. It logs the error and
returns 1 without starting OpenModelica. Other status errors keep the
fresh-compile fallback.
@raorjun
raorjun added this pull request to stack #159 October 25, 2026 00:43
@raorjun
raorjun requested a review from rhorvath02 October 25, 2026 02:43
@raorjun
raorjun merged commit 099d0b3 into main Oct 29, 2026
5 of 6 checks passed
@raorjun
raorjun deleted the fix/generator-boblib-root branch October 29, 2026 22:20
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