Skip to content

chore: export the control surface for the engine contract - #59

Merged
AdamMusa merged 1 commit into
mainfrom
chore/control-surface-export
Nov 2, 2026
Merged

AdamMusa merged 1 commit into
mainfrom
chore/control-surface-export

Conversation

@AdamMusa

@AdamMusa AdamMusa commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

What

Adds tools/control_surface.rb, the ruflet-owned export of the Ruby control surface (lead decision DC-8: the ruflet repo owns the generator; the engine and the template consume its JSON). It is the input of the engine's new control-core contract test, rule C3 ("each shared core spec declares exactly what Ruby can send").

Engine counterpart: AdamMusa/ruflet-engine#81 (refactor/control-core-foundation). The engine checks in a copy produced by this tool and refreshes it with packages/ruflet/tool/sync_ruby_surface.rb --ruby <ruflet checkout>; engine CI never needs a ruflet checkout.

Usage

ruby tools/control_surface.rb               # print JSON
ruby tools/control_surface.rb --out PATH    # write PATH
ruby tools/control_surface.rb --check PATH  # exit 1 when PATH is stale

Output (contract version 2)

Same entry format as the template's generate_ruflet_control_surface.rb (v1), plus:

  • every entry gains canonical (true/false) and alias_of (the canonical DSL name of its wire type: cupertino_switch -> switch, alertdialog -> alert_dialog);
  • wire_types: per wire type its canonical name, family, DSL names and the union of keywords of every class that sends it (what the engine compares a spec with);
  • common_attributes: the factory-wide wire attributes (flip, transform; ref stays in Ruby);
  • summary.canonical_entries.

Deliberate differences from the template's v1 data (both make the export match what ControlFactory.build actually does):

v1 (template) v2 (this tool)
visual names Controls::RufletControls::CLASS_MAP the factory's map (registry + the canonical platform contracts it merges last), so switch reports the union contract class and contract-only names (picker, timer_picker, action_sheet, context_menu_action, elevated_button + spellings) are listed: 348 -> 359 visual entries
keywords KEYWORDS or [] ControlFactory.constructor_keywords (+ ATTRIBUTE_OVERRIDES), so classes without a KEYWORDS constant (e.g. RadioGroup) list their real keywords

The template's conformance test hard-codes the v1 counts (386/348/38/205); switching the template to this file is the integrator's job (D-5) and needs those counts updated (397/359/38/205).

Tests

packages/ruflet_core/test/control_surface_export_test.rb (runs in CI with the rest of ruflet_core): every factory name is exported; entries name the class the factory builds; aliases point at the canonical name of the same wire type; wire-type unions; classes without KEYWORDS; --out/--check round trip and stale detection.

Verified with team/verify_pr.sh "" <this worktree> (RUBY_PKGS="ruflet_core ruflet ruflet_server ruflet_rails"): ruflet_core 146/146 files (639 runs), ruflet 13/13, ruflet_server 11/11, ruflet_rails 15/15. PASS. No library code changes; mruby is not involved (CRuby tool only).

Dependencies

None. New files only.

Add tools/control_surface.rb, the ruflet-owned export of every DSL name the
control factory resolves and every service: its wire type, the keywords it
accepts, whether it is the canonical name of its wire type (alias_of
otherwise), and per wire type the union of keywords of every class sending
it. The engine's control-core contract test compares each shared core spec
with this union; the template's conformance check can read the same file.
Contract version 2 of the template's surface format.
@AdamMusa
AdamMusa merged commit 574c049 into main Nov 2, 2026
12 checks passed
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