Repository navigation
feat: add design-neutral control core - #81
Merged
AdamMusa merged 1 commit intoNov 2, 2026
Merged
Conversation
This was referenced Oct 29, 2026
Add the shared control kernel every control will migrate onto: a pure-data ControlSpec, PropReader as the only reader of wire keys, ControlEvents as the only event dispatcher, ControlCore/FocusableCore for client state and focus, and CoreHost as the single owner of a control's invoke listener and layout keywords (re-bound when Ruby replaces the control in place). ToggleLabel, TileToggleCore, CoreSemantics, RawProp and TextOrWidget are the neutral pieces the first migrations share. The control-core contract test checks every migrated control against rules C1-C8 (skin isolation, core purity, spec equals Ruby KEYWORDS, skin consumption, lifecycle, completeness, event and semantics parity, and a report-only legacy ratchet). The manifest starts empty; the runtime rules run against a test-only probe core and the static rules against adversarial fixtures. The JSON snapshot harness and the Ruby control surface copy (with tool/sync_ruby_surface.rb) support the migration PRs.
AdamMusa
force-pushed
the
refactor/control-core-foundation
branch
from
October 29, 2026 00:56
9fb2161 to
02c2d4b
Compare
This was referenced Oct 29, 2026
AdamMusa
pushed a commit
that referenced
this pull request
Nov 3, 2026
Follow-up to #81 (design-neutral control core). PropReader resolves every theme-dependent value against RufletStyleTheme.of(context), and on iOS that was the root scope the Cupertino app renderer computes once outside any dialog. The pre-core Cupertino renderers resolved their state maps against cupertinoStyleTheme(context) at the control, which sees the CupertinoUserInterfaceLevel.elevated that CupertinoAlertDialog, action sheets, modal popups and sheets install. So in dark mode a Switch `thumb_color: {selected: "surface"}` or a Checkbox `fill_color` / `border_side` / `label_style` inside a Ruby AlertDialog or BottomSheet became 0xFF000000 instead of the elevated 0xFF1C1C1E. RufletStyleThemeScope can now carry a design-supplied `localTheme` that RufletStyleTheme.of consults for the reading context. The Cupertino app renderer and CupertinoControlTheme install their scope through the new cupertinoStyleThemeScope, which returns the theme for the reader's own interface level when it differs from the scope's (each level resolved once per scope). The kernel and style_theme.dart stay design-neutral, and Material scopes set no localTheme, so Material is unchanged. Plain colours read on an elevated surface now get the elevated shade too, so a control's `active_track_color: "surface"` and `thumb_color` no longer disagree (before #81 plain colours stayed on the root shade). elevated_surface_colors_test.dart mounts through the real PlatformApp in dark mode with one control of every migrated core (Switch, Checkbox, Radio, Button, IconButton, ListTile, ProgressRing, AppBar) painting "surface": base shade on the page, elevated in an AlertDialog and a BottomSheet and under a control theme in a dialog, and the theme surface in a Material dialog. The dialog and sheet cases fail without the fix (every core gave 0xFF000000). The harness installs the same scope as the app renderer. test/architecture: 298/298; dialog, sheet, Cupertino, snapshot, theme and core widget tests: 1076/1076. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MqfxcsDiEUZngybe9L72JQ
This was referenced Nov 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Foundation (F0) of the shared design-neutral core + thin native skins (DECOUPLING_SPEC §2–§4, lead decisions DC-1..DC-9). New files only, no behaviour change: nothing in
lib/uses the core yet; Switch, Checkbox and Radio migrate onto it in the stacked PRs that follow.Kernel (
lib/src/core/, widgets layer only)control_spec.dartControlSpec/PropSpec/EventSpec/MethodSpec(pure data,toJson()for reuse, DC-9): every key Ruby can send, every event and method, and which skins must honor each, with a mandatoryreasonfor single-skin entries.control_core.dart(+ partsprop_reader.dart,control_events.dart,core_host.dart)Controlstays library-private (DC-1).ControlCore<P>(typed props parsed once per build,@protectedlifecycle,writeBack,markNeedsBuild,decorate, sharedstates),FocusableCore(one FocusNode,focus/blurevents and methods),PropReader(the only caller ofcontrol.getX; debug asserts on undeclared keys or wrong types,CoreReadLogfor C6),ControlEvents(the onlytriggerEventcall site; callbacks are null without a subscription or while disabled unlesswhileDisabled),CoreHost(the only invoke listener, layout wrapper and props parse; moves its listener when Ruby replaces the Control in place; removes it on unmount).toggle_label.dartToggleLabel(one merged semantics node, one tap target, click cursor while enabled) andTileToggleCore(onetoggle_inputsListTile subscription per core, ignored while disabled).core_semantics.dart,raw_prop.dart,text_or_widget.dartContract test (
test/architecture/control_core_contract_test.dart)Driven by
test/architecture/core_manifest.dart(empty here; one entry per migration PR):showlist, noControl/triggerEvent/updateProperties/invoke-listener/LayoutControl/BaseControltokens);flutter analyze(fatal warnings) covers the@protectedmembers.PlatformDependencyGraph: the kernel and every manifest core import no design and reach neither.legacy_renderers.txt(88 design files on the old Control pattern) only shrinks; report-only until the queue drains (DC-6,enforceLegacyRatchet).The static rules are pure functions in
test/support/core_contract.dart, proven with adversarial fixtures; C5–C7 also run against a test-only probe core (test/support/core_probe.dart), so the runners are proven while the manifest is empty.Snapshot harness and Ruby surface
test/support/control_harness.dart,test/support/control_snapshot.dart: JSON snapshots (geometry, exposed semantics, messages sent to Ruby per scripted step, invoke outcomes), rewritten only with--update-goldens. Migration PRs commit them against the legacy renderer first.test/contract/ruflet_control_surface.json: generated by chore: export the control surface for the engine contract ruflet#59 (tools/control_surface.rb, contract v2) from rufletmain@ 816c862f; refresh withruby tool/sync_ruby_surface.rb --ruby <ruflet checkout> [--check]. Engine CI only reads the copy.Adaptations of the spec (documented, minimal)
ControlSpec.sharedLayoutKeys(new): keys the core reads whileLayoutControlstill applies them. The spec's Switch sketch ownswidth/height, which makesLayoutControlskip sizing entirely and would dropanimate_sizefor sized toggles; the legacy renderers letLayoutControlsize and scaled inside.ownedLayoutKeyskeeps the spec meaning (wrapper skips them, e.g. a future ListSectionmargin).PropTypesstateBorderSideandoutlinedBorder(Checkboxborder_side/shape), andPropReader.optionalBoolean/has.textOrWidgetreturns a neutralTextOrWidgetvalue instead of aWidget, so each skin styles plain-text labels natively while child-control labels keep their own style (exactly the legacy behaviour).CoreHostthrows fix: fail fast on invoke methods no handler claims #59'sUnsupportedErrortext itself for a method its spec does not declare. With exactly one listener per migrated control, nothing else can claim the name, so this is the fail-fast F2 will generalize; F2 (Control.declinedInvoke) switches it to the sentinel once fix: never crash invoke handlers on nil or missing args #52/fix: fail fast on invoke methods no handler claims #59 land. Invoke args are normalized like fix: never crash invoke handlers on nil or missing args #52'sinvokeArgs(private copy until fix: never crash invoke handlers on nil or missing args #52 merges).OverlayCore/CoreBuilder/dialog routes and skin ports are not in F0: the spec introduces them with AlertDialog (item 12) and CarouselView; C4 already checks ports via the manifest'sportInterface.common_attributes(flip,transform): every Ruby control accepts them andLayoutControlapplies them.Round 2: QA review changes (all twelve QA mutations now fail the contract test)
QA's mutation run (
$SP/qa/contract_mutations.sh, re-run against the rebased Switch tree) now gives 12/12 failing: M4 is caught by C4, M8 by C2b and M12 by C7. Each mutation is also checked into the contract test as a negative fixture (group "QA mutations").PropSpec.consumer(PropConsumer.skinsby default, orPropConsumer.core). C4 now requires every listed skin to reference a skin-consumed field, whatever the core does (M4). A core-consumed field must be referenced by the core, by no skin, and must apply to both skins.lib/src/corelibrary follows C1's import and token bans (Control, the Control model/extension libraries, the public barrel...). Core class constructors may only forwardsuper.parameters: no other parameters, no initializers, and the parameters are not used in the body.dynamicis banned in skins and cores, which closes the untyped variant (ToggleCore(dynamic c) : qa = c, super(c)). Only the kernel library (control_core.dart+ parts) holds a Control.PropReader.raw()could hand a child Control to a skinControl.RawPropequality is now deep.nativeWidgetsper skin; the newSnapshotStep.tapNative()taps it with a pointer. C7 fails if the script has notap nativestep or if any step could not run (M12).CoreHostanswers a debug-only census method;Control.invokeMethodreturns one result per listener (a list for several), and a foreign listener that rejects the name fails the call. This is done without touchingmodels/control.dart, which open PRs #52/#59/#79 edit. In release builds the census name is an ordinary undeclared method.EventSource.coreevent on both designs;SnapshotStep.unfocus()drivesblur. An event a script truly cannot drive must be listed inunexercisedEventswith a reason.invokeArgsTODO(#52).The runtime rules now return their problems instead of asserting, so the negative fixtures can prove them: M11 uses a forgetful probe core (C6), M12 a probe whose Material skin inverts the value (C7), and (E) adds a stray and a rejecting listener (C5). M10 mutates the kernel itself; C5 catches it on the real host, as QA confirmed.
Tests
test/core/control_core_test.dart(26, incl. theraw()guard): one skin per design; one parse per build with previous props;markNeedsBuild;decorate; layout/base/none wrappers and skipped owned keys; everyPropTypeparser (+ typed child lists); undeclared/wrong-type reads assert; subscribed-only events after the write-back; null callbacks without a subscription or while disabled (whileDisabledkept); undeclared events assert; declared method answered by exactly one listener (scalar result); nil args; undeclared or unhandled methods fail fast with fix: fail fast on invoke methods no handler claims #59's message; in-place control replacement re-binds the listener (old 0 / new 1, invokes and events reach the new instance, same element and core); unmount unregisters and disposes (incl. the FocusNode); focus/blur identical on both designs.test/core/toggle_label_test.dart(8),test/core/core_values_test.dart(5),test/core/control_snapshot_test.dart(4).test/architecture/control_core_contract_test.dart(C1–C8 incl. C2b, adversarial fixtures, probe runners, and the 12 QA mutations as negative fixtures).team/verify_pr.shon head 02c2d4b (base 81609d0) with rufletorigin/main(b5fd1694): PASS: engineflutter test+945 all passed,flutter analyze lib testno issues, ruflet_core 153/153 files (687 runs), wire-key audit 0 new findings. (Round 1 was 9fb2161, +834.)Dependencies
gh pr listfile check onlib/src/core/,test/architecture/,test/support/,test/contract/,test/core/,tool/). New files only, so it merges cleanly onto any base.