Warnings
Non-blocking accessibility and readability checks on a theme config, returned as structured warnings (the MCP tools report the same ones).
Validation throws on a config the engines cannot use. Beyond that, cortex has a softer set of “this works, but it’s probably not what you want” checks that return a ThemeWarning[] and never stop generation. Run them in your build to steer a theme toward better defaults without blocking releases. The default config and every built-in scenario raise none.
import {
collectTypographyWarnings,
collectElevationWarnings,
collectColorWarnings,
collectSizeWarnings,
collectThemeWarnings,
type ThemeWarning,
type WarningSeverity,
} from "@flexpixels/cortex";
const warnings: ThemeWarning[] = collectThemeWarnings(resolvedConfig);ThemeWarning shape
Every warning has the same shape:
interface ThemeWarning {
code: string; // SCREAMING_SNAKE_CASE stable identifier
severity: "info" | "warning" | "error";
message: string; // human-readable explanation
suggestedFix?: string; // remediation, written for both humans and agents
path?: string; // JSON-path-ish locator e.g. "typography.scale[2]"
role?: string; // type-style role name (typography-only)
}Functions
| Function | Domain | Notes |
|---|---|---|
collectTypographyWarnings(config) | Typography | Body size, line-height ratio, fluid range, weight gaps. |
collectElevationWarnings(config) | Elevation | Style ↔ accessibility conflicts, glass opacity, brutalism offset, light-mode shadow visibility, level-alias bounds, neumorphic offset monotonicity. |
collectColorWarnings(config) | Colour | A seeds.surface anchor too light for a dark page or too dark for a light one; page text that cannot reach its floor under elevation.ambient; alpha tints the contract’s text cannot be read on; a brand fill that fades into the page; dark-only inputs in a light-only theme. |
collectSizeWarnings(config) | Size | A size tier’s minTarget under 24px (WCAG 2.5.8). |
collectThemeWarnings(config) | Aggregate | Runs the typography, elevation, colour and size collectors, checks the focus ring, and returns one list. |
Typography rule codes
| Code | Severity | Triggered when |
|---|---|---|
TYPOGRAPHY_SMALLEST_SIZE_TINY | warning | Smallest typography.scale step < 12px. |
TYPOGRAPHY_BODY_TOO_SMALL | warning | Resolved body font-size < 16px. |
TYPOGRAPHY_BODY_LINE_HEIGHT_TIGHT | warning | Body’s line height as set (its role ratio, an explicit lineHeights entry, or a borrowed step) is below 1.4 of its size. |
TYPOGRAPHY_WEIGHT_GAP_LARGE | info | Two adjacent font weights differ by > 200. |
TYPOGRAPHY_FLUID_INVALID_RANGE | error | fluid.maxViewport <= minViewport — the clamp collapses. Validation already rejects this, so it only appears for an unvalidated config. |
TYPOGRAPHY_FLUID_RANGE_NARROW | info | Fluid viewport range < 200px wide. |
Elevation rule codes
| Code | Severity | Triggered when |
|---|---|---|
ELEVATION_NEUMORPHIC_AAA | warning | style: "neumorphic" paired with accessibility: "AAA" — the depth illusion needs low contrast. |
ELEVATION_GLASS_OPACITY_LOW | info | glassOpacity < 0.55 on liquid-glass — readability suffers on busy backgrounds. |
ELEVATION_BRUTALISM_OFFSET_TIMID | info | brutalismOffset < 3 on brutalism — the hard-shadow aesthetic stops reading. |
ELEVATION_SHADOW_TOO_FAINT | warning | 0 < shadowIntensity < 0.06 on flat/liquid-glass — the light-mode shadow is too faint to read. Exactly 0 (a design with no shadows) is not warned about. Dark mode uses shadowIntensityDark and is not affected. |
ELEVATION_ALIAS_OUT_OF_RANGE | error | A levelAliases entry maps to a level outside 1..4. Validation already rejects this, so it only appears for an unvalidated config. |
ELEVATION_NEUMORPHIC_OFFSETS_NON_MONOTONIC | info | scales.neumorphic.offsetSteps is not strictly increasing. |
Colour rule codes
| Code | Severity | Triggered when |
|---|---|---|
SURFACE_ANCHOR_TOO_LIGHT | warning | seeds.surface.dark is lighter than OKLCH L 0.3, so it no longer reads as a dark app background. |
SURFACE_ANCHOR_TOO_DARK | warning | seeds.surface.light is darker than OKLCH L 0.85, so it no longer reads as a light app background. |
COLOR_DARK_INPUT_UNUSED | info | settings.schemes is "light" and the config sets seeds.surface.dark or a non-default elevation.shadowIntensityDark, which only shape the dark scheme. |
COLOR_LIGHT_INPUT_UNUSED | info | settings.schemes is "dark" and the config sets seeds.surface.light, which only shapes the light scheme. |
AMBIENT_PAGE_TEXT_SHORT | warning | Under elevation.ambient, or on a page moved by seeds.surface, a page-text token cannot reach its WCAG floor everywhere on the page; the engine sets it to the best colour there is. |
TINT_TEXT_SHORT | warning | The contract’s text on a role’s alpha tint (a1–a4 over neutral 1–3) falls under 4.5:1 as rendered. The engine holds a tint’s lightness to where its text reads, so this means the page under the tint is itself too close to that text (a dark surface lifted too far). |
BRAND_FILL_FAINT_ON_PAGE | info | A brand role’s step 9 (the seed, in both schemes) is under 1.5:1 on the page, so a solid fill has no visible edge there. Outline it with --fp-{role}-border. |
Size rule codes
| Code | Severity | Triggered when |
|---|---|---|
SIZE_TARGET_BELOW_MINIMUM | warning | A sizes.{tier}.minTarget is under 24px, the hit area WCAG 2.5.8 asks for. |
Focus ring codes
Raised by collectThemeWarnings.
| Code | Severity | Triggered when |
|---|---|---|
FOCUS_RING_THIN | warning | interaction.focusRing.width is above 0 but under 2px, smaller than the indicator WCAG 2.4.13 Focus Appearance (AAA) asks for. |
FOCUS_RING_REMOVED | warning | interaction.focusRing.width is 0: a focused control shows no ring, which fails WCAG 2.4.7 Focus Visible unless each component draws its own. |
Wiring into CI
Run the aggregate collector against the resolved config in your build script and fail the build only on severity: "error" — log the rest:
import { collectThemeWarnings, loadUserConfig } from "@flexpixels/cortex";
const config = loadUserConfig("theme-config.json");
const warnings = collectThemeWarnings(config);
const errors = warnings.filter((w) => w.severity === "error");
const others = warnings.filter((w) => w.severity !== "error");
others.forEach((w) => console.warn(`[${w.severity}] ${w.code}: ${w.message}`));
if (errors.length > 0) {
errors.forEach((w) => console.error(`[error] ${w.code}: ${w.message}`));
process.exit(1);
}Where else they appear
The MCP servers (@flexpixels/cortex-mcp and @flexpixels/mcp) return the same code, severity and suggestedFix strings: the typography tools (compute_typography, validate_typography, suggest_type_scale) include typography warnings, and the elevation tools (compute_elevation, validate_elevation, suggest_elevation_style) include elevation warnings. validate_theme_config checks the schema only.
Loader warnings
loadUserConfig writes console warnings, not ThemeWarnings: CONFIG_NOT_FOUND when a path you wrote out is not there (silent for the default theme-config.json), and CONFIG_LOAD_FAILED when the file cannot be read, parsed or validated. Both fall back to the default theme; loadConfigFromPath throws instead.