From 604697b42ba83424e9ea432d5ed32b2538444c65 Mon Sep 17 00:00:00 2001 From: Victor Velazquez Date: Sun, 22 Nov 2026 17:28:25 +0100 Subject: [PATCH 1/4] Pin the slice D contracts --- docs/specs/PHASE-32-SPEC.md | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/docs/specs/PHASE-32-SPEC.md b/docs/specs/PHASE-32-SPEC.md index c00ad03..4f04b52 100644 --- a/docs/specs/PHASE-32-SPEC.md +++ b/docs/specs/PHASE-32-SPEC.md @@ -63,7 +63,7 @@ And one is housekeeping the follow-ups will land in. 140 tests and `test-env.ts` | **FR-C5** | **Tints and `danger` derive.** `applyStructure` stops seeding `accent-tint`, `success-tint`, `warning-tint`, `danger-tint`, `neutral-tint` and `danger`. A missing `danger` resolves to `error`, then to `#DC2626` (the literal `applyPrimitiveDefaults` already ends on). A tint missing from the merged tokens derives from its ink with the generator's own `tintLayer` (`src/color-system.ts:279`): `accent` (through the `accent`, `primary`, `#2563EB` chain `applyControlDefaults` uses), `success` (else `#16A34A`), `warning` (else `#D97706`), `danger` (with its fallbacks), and `text-secondary` (else `#6B7280`) for `neutral`, the literal fallbacks being the ones the code already uses. An ink with alpha (the dark preset's `text-secondary` is `#ffffffa0`) is composited over the surface first. The mode follows the surface, not the theme flag, because `apply_preset dark` and every unthemed stamp put a dark palette in the base layer with no theme set: the surface is `bg-surface`, else `bg-primary`, else white, and the mode is dark when that color contrasts more with white than with black. The `accent-tint` fallback at `variables.ts:230` (a 12% mix) routes through the same helper, so `nav-item` and `tree-row` match what `generate_design_system` emits. This FR fixes the tint, not the ink: preset inks such as the light preset's `success` `#16a34a` fall below 4.5:1 even on white, and the existing contrast check keeps reporting that as it does today. | `status-chip` then `apply_preset light` renders a tint in light mode (it contrasts more with black than with white); under `apply_preset dark`, and unthemed, the tint is in dark mode. Under a generated system the chip's ink clears 4.5:1 on the derived tint in both themes. `settings-app` then `apply_preset light` draws its danger action in the light preset's `error`; unthemed, it resolves with no unknown-token finding. | | **FR-C6** | **Old seeds count as unset.** `getCanvasTokens` (`src/workspaces.ts:360`) drops a canvas-layer tint or `danger` token whose value equals its old seed (`structures.ts:1865-1873`, compared case-insensitively) before merging, so a workspace or project token of that name shows through, and with none the name derives (FR-C5). This is the one place a canvas token yields to an inherited one; the normal precedence (canvas over project over workspace) is unchanged for every other value. Stored JSON is not rewritten. Render, evaluate and the viewer all read tokens through `getCanvasTokens`, so they agree. The version hash (`canvasVersionHash`, `src/version.ts:67`) reads them too, so a canvas holding a seed gets a new `sha256r:` hash once and a recorded approval of it reads STALE; that is correct, since its render changed, and the release notes say so. | A canvas stored with `success-tint: "#0f2e1b"` renders the derived tint under a light preset; one holding `#0F2E1C` keeps it. A canvas holding the seed under a workspace that generated `success-tint` renders the workspace's value. A canvas holding no seed keeps its version hash. | | **FR-D1** | **`select` has a boundary.** `select`'s default stroke becomes `$border-strong` when the token exists, on every type, as FR-B8 of Phase 31 did for `text-input` and the controls; canvases without the token keep `$border`. `desktop-app-boundary` measures `select`, against its own fill as it does for `text-input` (`boundaryPairs` picks the field fill per type at `state-checks.ts:268`; `select` gains its branch). PHASE-31-SPEC R7 is superseded. | A `select` under a generated system measures 3:1 or more and passes; a `select` with `stroke: "$border"` at 1.46:1 on a desktop-app canvas warns; a canvas without `border-strong` renders unchanged. | -| **FR-D2** | **`tree-row` shows where you are.** An active `tree-row` draws `nav-item`'s 2px leading bar in `$accent` (`renderer.ts:1537`), at the row's left edge before the indent, so it lines up across depths; the row takes `position: relative` with the same guard `renderNavItem` uses (none when the node is itself positioned), and keeps `positionStyles`. `indicatorPairs` measures it like a `nav-item`, in rest and hover. The render-versus-model test (`test-state-model-render.ts`) adds an active `tree-row` and a `select`. PHASE-31-SPEC R4 is superseded for `tree-row`. | An active `tree-row` renders the bar at x = 0 at depth 0, 1 and 2; a bar resolving to 2.5:1 against its active fill warns; the model and the render agree. | +| **FR-D2** | **`tree-row` shows where you are.** An active `tree-row` draws `nav-item`'s 2px leading bar in `$accent` (`renderer.ts:1515`), at the row's left edge before the indent, so it lines up across depths; the row takes `position: relative` with the same guard `renderNavItem` uses (none when the node is itself positioned), and keeps `positionStyles`. `indicatorPairs` measures it like a `nav-item`, in rest and hover. The render-versus-model test (`test-state-model-render.ts`) adds an active `tree-row` and a `select`. PHASE-31-SPEC R4 is superseded for `tree-row`. | An active `tree-row` renders the bar at x = 0 at depth 0, 1 and 2; a bar resolving to 2.5:1 against its active fill warns; the model and the render agree. | | **FR-D3** | **Contained tabs stay as they are.** The active contained tab is a filled segment with a heavier label; the fill is the indicator and the weight is the non-color cue. It draws no bar and is not measured by `desktop-app-state-contrast`; GUIDELINES, the `tabs` docstring and the `canvas_evaluate` docstring say so and why. | The docs state it; contained tabs render unchanged. | | **FR-D4** | **Stress exercises counts.** `nav-item` `count` and `tabs` `items[].count` join `PRIMITIVE_TEXT_PROPS`, and `propSlots` (`stress.ts:84`) accepts numbers as well as strings, so the `big-numbers` perturbation widens `42` to `999+`. | `applyPerturbation('big-numbers')` on a `nav-item` with `count: 42` (a number) and a `tabs` node with an item `count: "7"` touches both nodes and sets both counts to `999+`; `canvas_stress` on that canvas reports `touchedCount` 2 for `big-numbers` (its output has no per-node list, `index.ts:2347`). | | **FR-E1** | **`link` and `text-input` are phone targets.** The touch branch of `checkUsability` (`evaluate.ts:2155-2165`) measures both at 44, delegating their boxes to the desktop census's measurement (`desktopTargets`), not by adding them to `TAPPABLE_PRIMITIVES`: that set feeds `CLICKABLE_PRIMITIVES` (`primitives.ts:45`) and is checked first in `pointerTargets` (`evaluate.ts:2016`), so adding them there would drop them from the 24px census. `link` already honors `height` (`renderLink`, min 24). `text-input`'s `size` union already lists `"lg"`, but `TEXT_INPUT_HEIGHT` (`primitives.ts:38`) and `textInputHeight` (`:203`) treat it as 40; it becomes 44. Inline link ranges stay exempt, as on web. The pin at `test-desktop-primitives.ts:142-143` flips. | On a mobile canvas a 40px `text-input` and a default (24px) `link` are `mobile-touch-target` errors; `size: "lg"` and `height: 44` clear them. On desktop-app, both stay in the 24px census and `lg` measures 44. | @@ -172,16 +172,26 @@ And one is housekeeping the follow-ups will land in. 140 tests and `test-env.ts` These fixes were proved red on 2cff888 and green after; no agent re-verified them. **Slice D: desktop-app checks and stress (FR-D1 to FR-D4).** -- `variables.ts` select branch: `$border-strong` when defined. `state-checks.ts:268`: `select` measured. +- `variables.ts` select branch: `$border-strong` when defined. `state-checks.ts:279` (`boundaryPairs`): `select` measured. - `renderTreeRow` (`renderer.ts:1610`): `position: relative` with `renderNavItem`'s guard, and the bar. `indicatorPairs` (`state-checks.ts:211-236`): `tree-row`. - `stress.ts:45-68`: the two count slots; `propSlots` (`:84`) stringifies numbers. +**Slice D — contracts pinned before build (2026-11-22; frozen at the commit that adds this block).** Drafted, then broken on paper by one pre-freeze verifier (9 findings, 7 confirmed); this is the re-frozen version. Departures from the draft are marked *(changed)*. +- **Q1: the `select` default.** `applyControlDefaults`' select branch sets an unset `stroke` to `colors['border-strong']`, else `colors.border`, else the existing fallback, on every type (the same `boundary` the controls use). Explicit strokes win. No stamp seeds a new token. Presets define no `border-strong`, so a preset canvas keeps `$border`; generated systems define it on every type, so their selects move. *(changed)* A stamp seeds `border-strong` (`#666666`) when it holds a desktop primitive and the canvas resolves no `border` (`structures.ts:1939`, `:2119`): the two realisations holding a `select` (`editor-inspector-app`, `settings-app`) seed it unthemed, and stamped after a preset they seed nothing, so their selects warn there as their `text-input`s and toggles already do. That order is not gated today and stays a named limit; the finding's suggestion says to define `border-strong` (set_variables, or generate_design_system) when the canvas has none. The `sha256r:` hash does not move (no token changes). +- **Q2: `select` in `desktop-app-boundary`.** `boundaryPairs` measures a `select` that is not disabled, as it measures a `text-input`: the boundary is the node's `stroke` (unset, an unresolved `$ref`, `transparent` or `none` is measured as what shows there: the backdrop through the fill), the field is the node's `fill`, painted over the backdrop, and a field that clears 3:1 against the backdrop passes the control whatever its border. The finding names the part `border` and carries the fill clause. The rule still runs on desktop-app canvases only, in each theme the canvas has. Named false negatives, in the `desktop-app-boundary` docs *(changed)*: a disabled control (WCAG exempts it); web and mobile canvases (never measured, though Q1 strengthens their default); a backdrop that is a gradient or image, or a fill the checker cannot read (a CSS name such as `white`, `hsl()`), which is silent for `select` as it already is for `text-input` and the controls. +- **Q3: the `tree-row` bar.** An active `tree-row` renders, as the row's first child, the `nav-item` bar markup unchanged: `position: absolute; left: 0; top: 6px; bottom: 6px; width: 2px; border-radius: 1px; background-color: `. The row adds `position: relative` unless the node sets `position` (then `positionStyles` positions it and the bar anchors to that box). The bar ignores `depth`, so it sits at x = 0 of the row at every depth. It draws whenever `active` is set, disabled included, as `nav-item`'s does, and on every type; only desktop-app canvases measure it (named in the docs). +- **Q4: `tree-row` in `desktop-app-state-contrast`.** `indicatorPairs` pairs an active, not disabled `tree-row` exactly as a `nav-item`: indicator `iconColor` (else the accent fallback), fill `fill`, hover ink `color` (else the text fallback), the node's own opacity, the backdrop behind it; `what` is `tree-row