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.

ts
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:

ts
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

FunctionDomainNotes
collectTypographyWarnings(config)TypographyBody size, line-height ratio, fluid range, weight gaps.
collectElevationWarnings(config)ElevationStyle ↔ accessibility conflicts, glass opacity, brutalism offset, light-mode shadow visibility, level-alias bounds, neumorphic offset monotonicity.
collectColorWarnings(config)ColourA 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)SizeA size tier’s minTarget under 24px (WCAG 2.5.8).
collectThemeWarnings(config)AggregateRuns the typography, elevation, colour and size collectors, checks the focus ring, and returns one list.

Typography rule codes

CodeSeverityTriggered when
TYPOGRAPHY_SMALLEST_SIZE_TINYwarningSmallest typography.scale step < 12px.
TYPOGRAPHY_BODY_TOO_SMALLwarningResolved body font-size < 16px.
TYPOGRAPHY_BODY_LINE_HEIGHT_TIGHTwarningBody’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_LARGEinfoTwo adjacent font weights differ by > 200.
TYPOGRAPHY_FLUID_INVALID_RANGEerrorfluid.maxViewport <= minViewport — the clamp collapses. Validation already rejects this, so it only appears for an unvalidated config.
TYPOGRAPHY_FLUID_RANGE_NARROWinfoFluid viewport range < 200px wide.

Elevation rule codes

CodeSeverityTriggered when
ELEVATION_NEUMORPHIC_AAAwarningstyle: "neumorphic" paired with accessibility: "AAA" — the depth illusion needs low contrast.
ELEVATION_GLASS_OPACITY_LOWinfoglassOpacity < 0.55 on liquid-glass — readability suffers on busy backgrounds.
ELEVATION_BRUTALISM_OFFSET_TIMIDinfobrutalismOffset < 3 on brutalism — the hard-shadow aesthetic stops reading.
ELEVATION_SHADOW_TOO_FAINTwarning0 < 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_RANGEerrorA 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_MONOTONICinfoscales.neumorphic.offsetSteps is not strictly increasing.

Colour rule codes

CodeSeverityTriggered when
SURFACE_ANCHOR_TOO_LIGHTwarningseeds.surface.dark is lighter than OKLCH L 0.3, so it no longer reads as a dark app background.
SURFACE_ANCHOR_TOO_DARKwarningseeds.surface.light is darker than OKLCH L 0.85, so it no longer reads as a light app background.
COLOR_DARK_INPUT_UNUSEDinfosettings.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_UNUSEDinfosettings.schemes is "dark" and the config sets seeds.surface.light, which only shapes the light scheme.
AMBIENT_PAGE_TEXT_SHORTwarningUnder 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_SHORTwarningThe 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_PAGEinfoA 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

CodeSeverityTriggered when
SIZE_TARGET_BELOW_MINIMUMwarningA sizes.{tier}.minTarget is under 24px, the hit area WCAG 2.5.8 asks for.

Focus ring codes

Raised by collectThemeWarnings.

CodeSeverityTriggered when
FOCUS_RING_THINwarninginteraction.focusRing.width is above 0 but under 2px, smaller than the indicator WCAG 2.4.13 Focus Appearance (AAA) asks for.
FOCUS_RING_REMOVEDwarninginteraction.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:

ts
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.