@micha.bigler/ui-core-micha 2.33.0 → 2.33.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,185 @@
1
+ # THEME-4 — Make it impossible for a kit component to silently defeat the baseline
2
+
3
+ **Target repo:** `ui-core-micha` (branch `main` — this repo has no `develop`)
4
+ **Tier:** 3 (shared core)
5
+ **Review:** independent `reviewer` — mandatory (new logic). **`ui_reviewer` becomes mandatory too if
6
+ the check surfaces findings that require touching a component's rendering**, which is likely; see
7
+ "What test 2 will probably do".
8
+ **Version target:** the next **minor** after `THEME-3` lands — a new exported check is additive API.
9
+ Read the published version at implementation time; do **not** hardcode a number from this file.
10
+ **Strand:** `DS-18`, first half
11
+ **Sequencing:** **after `THEME-3`.** See Risks — that work order is in flight in these exact files.
12
+
13
+ ---
14
+
15
+ ## A. Envelope
16
+
17
+ ### Goal
18
+
19
+ A kit component can put a property in its own `sx` that the baseline already sets as a
20
+ `styleOverrides` default. Inline `sx` wins, so the baseline default becomes inert — the theme is
21
+ complete, green, and has no effect.
22
+
23
+ This is not hypothetical. It happened in `SHELL-3`: `MobileBottomNav` duplicated `borderTop` and
24
+ `borderColor` inline, killing the two defaults the same work order had just registered.
25
+ `SHELL-4` fixed it by hand and added a test asserting key-disjointness for that one component
26
+ (`tests/MobileBottomNav.test.jsx:215`). **Make that mechanical for the whole kit.**
27
+
28
+ ### Why the whole kit, measured
29
+
30
+ - **51 `.jsx` files under `src/` carry an `sx=` prop.**
31
+ - **The baseline styles 23 MUI component keys** — `MuiAlert`, `MuiBottomNavigation`,
32
+ `MuiBottomNavigationAction`, `MuiButton`, `MuiCard`, `MuiCheckbox`, `MuiChip`, `MuiContainer`,
33
+ `MuiCssBaseline`, `MuiDialog`, `MuiDivider`, `MuiDrawer`, `MuiFilledInput`, `MuiFormControlLabel`,
34
+ `MuiIconButton`, `MuiInput`, `MuiMenu`, `MuiOutlinedInput`, `MuiPaper`, `MuiSelect`,
35
+ `MuiTableCell`, `MuiTextField`, `MuiTooltip`.
36
+ - `SHELL-4`'s test covers **one** component pair. The other 50 files are unchecked.
37
+
38
+ `MobileBottomNav` was not special. `ChartFrame`, `UserMenu`, `LoginForm`, `PageLayout` and the input
39
+ managers all render MUI components the baseline styles **and** carry their own `sx`.
40
+
41
+ ### Why the assertion cannot see this
42
+
43
+ `assertThemeComplete` proves the theme **has** a value; nothing proves any component **uses** it.
44
+ And a hex-value grep does not catch it either, because the duplicated value is usually *correct* — it
45
+ is in the wrong layer, not the wrong colour. Reviewing for "no hardcoded colours" passes it. The one
46
+ thing that caught it was a human reading a diff.
47
+
48
+ ### Scope
49
+
50
+ **1. A convention, already demonstrated.** A kit component that carries its own `sx` for a MUI
51
+ component the baseline styles **exports that `sx` object**. `MobileBottomNav` already does
52
+ (`MOBILE_BOTTOM_NAV_ROOT_SX`, `MOBILE_BOTTOM_NAV_ACTION_SX`) — follow that shape rather than
53
+ inventing a second one. A small registry maps each exported object to the MUI key it targets.
54
+
55
+ **2. An exported check.** Same finding contract as the existing assertion —
56
+ `{ findings: [{ surface, reason }] }` — so consumers and tests handle one shape, not two. For each
57
+ registry entry, assert the key sets of the component's `sx` and the baseline's `styleOverrides` for
58
+ that MUI key are **disjoint**. A collision names the component, the MUI key and the property.
59
+
60
+ **3. A bypass check, so the convention cannot be skipped in silence.** A source-level scan that flags
61
+ a kit component file containing an inline `sx={{ … }}` object literal which is not exported.
62
+ **Precedent in this repo:** `reportThemeAdoption(sources)` already takes source strings and regexes
63
+ them for `createTheme(` versus `createAppTheme(` — same module, same shape, so this is an established
64
+ pattern here rather than a new mechanism.
65
+
66
+ **4. Wire it as a hard failure in ucm's own suite.**
67
+
68
+ **This check cannot turn any consuming app red.** It is entirely internal: ucm's components against
69
+ ucm's baseline, run in ucm's tests. An earlier concern that a new invariant might break cockpit's
70
+ fresh adoption was raised and, on designing it, does not apply — an app's *own* components shadowing
71
+ the baseline is the broader case and is a named follow-up below.
72
+
73
+ ### What test 2 will probably do, and what to do about it
74
+
75
+ **Expect findings.** 51 files have never been checked against 23 styled component keys. A clean first
76
+ run would be a pleasant surprise, not the base case.
77
+
78
+ - **Each finding is resolved by `SHELL-4`'s rule: one home per property.** The component owns what
79
+ keeps it functional on any theme; the theme owns what makes it look like this estate. A property in
80
+ both layers is the defect.
81
+ - **Do not exempt your way to green.** The exemption arm exists for a component that genuinely must
82
+ override the baseline for its own purpose, with a stated reason — the same contract
83
+ `assertThemeComplete` uses, where an exemption without a reason is itself a finding. A mass
84
+ exemption converts this work order into a no-op.
85
+ - **If the finding count is large enough that fixing them all exceeds this work order, stop and
86
+ report** with the list. Splitting into "land the check plus the fixes it can absorb" and "the
87
+ remainder as a follow-up" is a scope decision for the operator, not something to absorb silently.
88
+
89
+ ### Non-goals / do not touch
90
+
91
+ - **`DS-18`'s second half — "which components *can violate* a rule".** That is the shadow-array idea:
92
+ nine MUI components read `shadows[…]`, three are declared, six would become findings. It is
93
+ deliberately **out of scope** because it rests on a `grep 'shadows\['` **lower bound** and its
94
+ findings demand *new* theme entries — pressure toward the gold-plating the estate's YAGNI guardrail
95
+ rejects. Follow-up, with the heuristic labelled as a lower bound wherever it appears.
96
+ - **App-side scanning.** An app's own components can shadow the baseline too (a `Header` putting
97
+ `borderColor` in `sx` over a `MuiAppBar` default). Real, and a follow-up — `reportThemeAdoption`
98
+ already shows the shape for it.
99
+ - **No rendering-based check.** Asserting that each of 23 components tracks a changed theme needs a
100
+ fixture per component: expensive, fragile, and not what this WO buys. `SHELL-4`'s cross-theme
101
+ render test stays the pattern for individual components.
102
+ - **No baseline token or component-default change**, unless a finding forces one — and then it is a
103
+ fix, listed, not a redesign.
104
+ - No change to `assertThemeComplete`'s own surface registry, `createAppTheme`'s signature, or any
105
+ component's public props.
106
+
107
+ ### Risks
108
+
109
+ - **`THEME-3` is in flight in this repo right now.** Verified: `src/theme/tokens.js`,
110
+ `src/theme/themeCompleteness.js`, `tests/createAppTheme.test.js` and
111
+ `tests/themeCompleteness.test.js` are all modified in the working tree with Codex running. **Those
112
+ are exactly this work order's files.** Do not start concurrently: let `THEME-3` land and publish,
113
+ then `git pull` and work from that state. Check `git status` and `git log origin/main..HEAD` first.
114
+ - **The convention is only as strong as its adoption**, which is what item 3 exists to guarantee. If
115
+ item 3 is dropped, the check degrades to "whatever someone remembered to export".
116
+ - **Known bound, state it in the code rather than discovering it later:** the check sees only `sx`
117
+ objects a component exports, at their top level. A **conditional or nested** `sx` is not covered —
118
+ `MobileBottomNav`'s own `emphasis` circle is exactly such a case. This is a lower bound on
119
+ shadowing, not coverage, and must be documented as such so nobody reads green as proof.
120
+ - **No staging net.** A version bump on `main` publishes to npm; the independent review is the only
121
+ gate and cannot be back-filled.
122
+
123
+ ### Required tests to WRITE
124
+
125
+ 1. **Non-vacuity, reconstructing the real incident.** A fixture component whose exported `sx`
126
+ duplicates a baseline `styleOverrides` key produces a finding naming the component, the MUI key
127
+ and the property. This is `SHELL-3`'s arrangement; the test must fail if the check is inert.
128
+ 2. **The current kit.** Run the check across the whole registry and assert the result is empty —
129
+ after fixing whatever it legitimately finds (see above).
130
+ 3. **The bypass check** flags an inline non-exported `sx={{ … }}` in a fixture source string and does
131
+ **not** flag an exported one.
132
+ 4. **The exemption contract matches the existing one:** an exemption with a reason suppresses exactly
133
+ one finding; an exemption without a reason is itself a finding.
134
+ 5. `SHELL-4`'s existing `MobileBottomNav` disjointness test still passes, and is **not** replaced by
135
+ the generic check — the specific test documents that component's split, the generic one guards the
136
+ kit. Keeping both is deliberate.
137
+
138
+ Plus `tsc -p tsconfig.build.json --noEmit` clean. **No full-suite run** — the affected set is the
139
+ theme module's specs plus any component spec a fix touches.
140
+
141
+ ### Verification
142
+
143
+ Static work with no visual surface of its own, so the standing rendered gate does not apply **unless
144
+ a finding forces a component change** — then the two-width side-by-side applies to that component,
145
+ and `ui_reviewer` becomes mandatory alongside it. Say in the register note which of the two happened.
146
+
147
+ The check's own value is proven by test 1, not by a screenshot: a check that cannot fail is worth
148
+ nothing, and that is the assertion this work order actually has to make about itself.
149
+
150
+ ### Parity guardrail
151
+
152
+ No intended change to any rendered output. If the kit renders differently after this work order, it
153
+ is because a real shadowing defect was fixed — and every such change must be listed in the register
154
+ note, not folded in as tidying.
155
+
156
+ ---
157
+
158
+ ## B. Implementation map
159
+
160
+ *Filled by the Orchestrator on `git pull` — see `AGENTS.md` → "Work Order".*
161
+
162
+ ### Execution directive (read this first)
163
+
164
+ > **If you are the implementer reading this work order as your own specification: this section is
165
+ > NOT addressed to you.** It tells the Orchestrator how to invoke you. **You ARE that invocation —
166
+ > do NOT shell out to `codex exec`.**
167
+ >
168
+ > Implement through `codex exec` in the background — invoked directly via Bash (never the
169
+ > `debugger`/`*_coder` Agent wrappers) with BOTH flags `--skip-git-repo-check` and
170
+ > `--dangerously-bypass-approvals-and-sandbox`. **Pass the WO via stdin, not as a positional
171
+ > argument** (a positional arg hits Windows' command-line length limit — proven repeatedly in this
172
+ > repo). Fallback to direct Claude implementation only on Codex quota/rate-limit/non-zero exit — and
173
+ > note that the fallback flips authorship, so the independent `reviewer` stays mandatory either way.
174
+ >
175
+ > **Two things this repo has learned the hard way, both on the two immediately preceding work
176
+ > orders:** Codex committed its own change and wrote a self-reported review into
177
+ > `WORK_ORDERS.md` on `SHELL-3` **and** on `SHELL-4`. Read `git log origin/main..HEAD` and
178
+ > `git status` before your own review; an implementer commit is a blocker to surface, and a register
179
+ > row naming a review the Orchestrator did not itself start is invalid.
180
+
181
+ ### Mini-handover
182
+
183
+ Repo: `ui-core-micha` (`C:\Users\biglmi\Documents\webapps\ui-core-micha`), branch `main`.
184
+ WO: `work-orders/THEME-4.md`. **Wait for `THEME-3` to land and publish first** — same files.
185
+ Follow `orchestrate-codex`.