Skip to content

test: constrain registry entries to the canonical shape - #88

Merged
AdamMusa merged 3 commits into
codex/engine-initializationfrom
test/control-core-entry-shape-rule
Nov 2, 2026
Merged

AdamMusa merged 3 commits into
codex/engine-initializationfrom
test/control-core-entry-shape-rule

Conversation

@AdamMusa

@AdamMusa AdamMusa commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

Depends on #81 (control core foundation). Until #81 merges, this PR's diff also shows #81's commit; review the last two commits.

Why

QA's re-review of #81 found a gap: the registry entry (adaptive_*.dart) is the only place outside the kernel that legitimately holds the Control, and no rule constrained it. Two evasions passed the contract test:

  • N1: the entry injects wire data into a public core field: create: (c) => SwitchCore(c)..qaLeak = c.properties.
  • N4: the entry passes a raw wire value into a skin: MaterialSwitchSkin(core: core, qaExtra: control.properties['tooltip']).

What

Two commits:

  1. feat: let shared cores read their wire type and placement: ControlCore.wireType, parentWireType and parentSlot (protected, read-only; parentSlot is the parent property that holds the control, e.g. leading, which the IconButton family uses for the iOS back chevron of an AppBar's leading button). Under the new rule an entry may no longer branch on control.canonicalType/control.parent. A registry entry that serves several wire types still needs to pick a spec: the five Button types all build AdaptiveButtonControl, and the registry is not edited by migrations. Core constructors may only forward super.control (C2b). So the core now picks its own spec and variant from its wire type, and the entry stays create: ButtonCore.new. Unit tests: an alias (ElevatedButton) reads as its canonical type; the parent's type and slot are visible, for list slots (controls) and single-child slots (content).
  2. test: constrain registry entries to the canonical shape, which adds:
    • New rule C1e (entry shape), for every manifest entry:
      • CoreHost(create:) is a plain constructor tear-off (XCore.new).
      • The builder is (context, core) => PlatformControlRenderer(...). Each design closure builds its skin with only core: (the builder's core, nothing else) and key:, and may choose between skins only on the core (core.inAlertDialog ? A(core: core) : B(core: core)).
      • control appears only as CoreHost(control:), inside the host's key: and inside debugPrint(...).
    • C2b addition (QA's optional suggestion): cores and core mixins have no public mutable fields or setters, which closes N1 from the core side as well.
    • C1 now also covers helper skin libraries listed in the manifest (e.g. an iOS dialog-action skin used next to the main Cupertino skin).

Tests

team/verify_pr.sh on head ba72191 (with ruflet origin/main 43928509): PASS: engine flutter test +956 all passed, flutter analyze lib test no issues, ruflet_core 157/157 files (718 runs), wire-key audit 0 new findings.

Stack

Migrations from the Button family onward stack on this PR; the Button family PR follows. #84/#86/#87 are approved and unchanged. Once this PR and they are merged, C1e runs on their entries automatically, and they already comply.

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.
Registry entries map several wire types to one host (the five Button types
all build AdaptiveButtonControl), and the entry-shape rule keeps entries from
reading the Control. Give ControlCore protected, read-only accessors for its
canonical wire type, its parent's, and the parent property that holds it, so
a core can choose its spec and rendering itself (a Button inside an
AlertDialog, an IconButton in an AppBar's leading slot) while its constructor
stays a plain super.control.
Add contract rule C1e for the registry entry, the one place outside the
kernel that holds the Control: CoreHost(create:) must be a constructor
tear-off, each PlatformControlRenderer closure builds its skin with only
core: (the builder's core) and key:, choosing between skins only on the
core, and control appears only as CoreHost(control:), inside the host key and
in debugPrint. C2b now also bans public mutable fields and setters on cores,
and C1 covers helper skin libraries.

QA's evasions N1 (an entry injects wire data into a core field) and N4 (an
entry passes a raw wire value to a skin) are negative fixtures; the three
approved entries (Switch, Checkbox, Radio) are positive fixtures, verbatim.
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