Skip to content

feat: Opal boot file and boot-file verification - #27

Merged
ronaldtse merged 1 commit into
mainfrom
feat/opal-specs-and-workflow
Jun 27, 2026
Merged

feat: Opal boot file and boot-file verification#27
ronaldtse merged 1 commit into
mainfrom
feat/opal-specs-and-workflow

Conversation

@ronaldtse

@ronaldtse ronaldtse commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds the canonical Opal entry point for unitsdb and a CI check that verifies it stays well-formed.

  • Adds lib/unitsdb/opal.rb: a single eager-require file that consumers (unitsml-ruby, plurimath-js) pass to Opal via -r unitsdb/opal. Under Opal, Ruby's autoload does not lazy-execute, so consumers need this canonical entry point rather than hand-listing files.
  • Adds spec/unitsdb/unitsdb_opal_boot_spec.rb: a static MRI-run spec that verifies:
    • The boot file eager-requires every unitsdb/*.rb file that lib/unitsdb.rb exposes.
    • The boot file does not leak Opal-gated entry points (cli, commands).
    • The boot file only references files that exist on disk.
    • The boot file actually compiles under Opal::Builder with the native-only lutaml/model dependency stubbed (the gem's consumer is responsible for providing a working lutaml-model bundle at runtime).
  • Adds .github/workflows/opal.yml to run the spec on every push and pull_request.
  • Adds opal (~> 1.8) to the Gemfile as a development dependency for the compile check.

Scope boundary

This PR establishes the contract between unitsdb-ruby and its Opal consumers — a single entry point and a CI check that it is well-formed. It does not make unitsdb-ruby itself run under Opal at runtime, because:

  • unitsdb-ruby uses Lutaml::Model::Serializable for every model class, so runtime Opal execution requires lutaml-model to work under Opal (separate concern, owned by lutaml-model and plurimath-js's bundle).
  • The boot file's job is to be compilable by Opal. The runtime bundle is the consumer's responsibility — plurimath-js already does this at bundle time via the boot file added here.

Test plan

  • bundle exec rspec spec/unitsdb/unitsdb_opal_boot_spec.rb — 4 examples, 0 failures locally.
  • bundle exec rake — 810 examples, 0 failures (no regression).
  • bundle exec rubocop — clean.
  • CI green on this PR.

Adds lib/unitsdb/opal.rb, a single eager-require entry point that
consumers (unitsml-ruby, plurimath-js) can pass to Opal via
`-r unitsdb/opal` to pull in every autoloadable unitsdb entry point
without hand-listing files. Under Opal, Ruby's autoload does not
lazy-execute, so consumers need this canonical entry point.

Adds spec/unitsdb/unitsdb_opal_boot_spec.rb which statically verifies
that the boot file:
- eager-requires every unitsdb/*.rb file that lib/unitsdb.rb exposes
- skips the Opal-gated Cli/Commands entry points
- only references files that exist on disk
- actually compiles under Opal::Builder with the native-only
  lutaml/model dependency stubbed (the gem's consumer is responsible
  for providing a working lutaml-model bundle at runtime.

Adds .github/workflows/opal.yml which runs the boot-file spec on every
push and pull_request.

Adds opal (~> 1.8) to the Gemfile as a development dependency for
the boot-file compile check.

The gem itself does not run under Opal at runtime in this PR — that
is plurimath-js's responsibility at bundle time. This PR establishes
the contract: a single entry point and a CI check that it is well-formed.
EOF
)
@ronaldtse
ronaldtse force-pushed the feat/opal-specs-and-workflow branch from da64084 to 47ed3bc Compare June 27, 2026 15:31
@ronaldtse
ronaldtse merged commit daf5d12 into main Jun 27, 2026
19 checks passed
@ronaldtse
ronaldtse deleted the feat/opal-specs-and-workflow branch June 27, 2026 15:36
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