responsive.sk

Article

Rust and Lekalo for kids ... part 10.1: design enters the model

Article cover illustration: Architecture, rust, lekalo, semantic-model

In part 9.2 themes got their routes and the model stood at 135 definitions. Today the fifth module arrives:
design. The model grows to 142 definitions and for the first time it does not describe behaviour but something a regular person pictures under the word design: colors, surfaces and contrast.

What's new in the model

Seven definitions in lekalo/modules/design/. The core is not a color but a token identity: a surface-and-mode pair plus a CSS custom property name.

DefinitionKindWhat it says
design.roleenumthe 7 roles the CSS audit actually contracts on
design.modeenum`dark \light`: the two audited blocks
design.variantenum6 surfaces: 4 themes + admin + auth
design.token_namescalara CSS custom property name, e.g. --st-accent-strong
design.identityentityidentity [variant, mode, token] + a role
design.resolve_tokensqueryreads the identities, pins the WCAG AA contract
design.contrast_flowscenariothe mode flips → the contrast holds in both

Plus two policies in authorization.yaml (13 in the project now):
reading is public, the admin carries a policy on the same read surface.

The role, not the value

The most important decision of this part: the model declares **which identities exist and under which role**, not which color they carry.
Colors are bytes in CSS and they stay in CSS.

design.role is not an invented list. It is exactly the seven suffixes BuildCssAuditTest guards with real WCAG computations: accent_strong, accent_soft, accent_hover, primary_ink, error_ink, surface, tag_bg. The decorative amber --mag-accent (about 3:1, icons and borders only) is deliberately not a role. Its contract is a text ban, not a floor.

And why accent_strong instead of accent-strong? Exactly. The first grammar lesson.

Two grammar lessons

Lesson 1: enum values are snake_case. The first lekalo validate run fell over on every accent-strong with LEK-IR-006. The analogy helped: the blog model has members_only, not members-only. The value grammar wants underscores and the model will not route around it.

Lesson 2: the closed schema refuses an empty applies_to. We wanted an honest admin policy without a command, so we wrote applies_to: [].
LEK-AUTH-001, no explanation. Bisecting: the block without the admin policy passes, the empty list does not, a filled list does. The schema does not want an empty commitment.

The fix is more honest than a placeholder: design.policy.admin_editing got the same read surface, design.resolve_tokens. The admin only reads the surface anyway. No fictional command was invented and the write side stays unmodeled because the runtime has none.

The pinned digest, this time in two places

After adding the module, validate --strict fell over with LEK-AUTH-010 (state: stale-model). The same lesson as in [part 9.1](/blog/lekalo-themes-enter-the-model), with extra weight:

  1. verify the recipe before using it → on the committed model it

produced exactly the pinned 23bdb373…,

  1. the new pin 6afbf0eb… → authorization.yaml,
  2. the same compact IR digest also goes into the irRef.digest of the

docs/lekalo/invariant-transition.nativa.json attachment (its old value matched the same recipe, so the recipe is twice-verified),

  1. the attachment's modelRef.digest is a lock contract and stays.

And lekalo.lock? Once again byte-identical. It freezes resolution identities, not model content.

The gate cannot read CSS, the test can

The pattern from part 9.1 got its second deployment:
tests/Integration/DesignModelParityTest.php, 5 tests.

  • design.variant must cover every surface the audit touches (parsed

from the audit source: --st-, --mag-, --min-, --m- from the bundle plus the adminCss() and authCss() inline blocks),

  • design.role must be set-equal with the audited role list,
  • design.mode must be exactly dark|light,
  • the contract shape: the identity fields, the query reads and

returns.

A new audited role without a model entry → CI fails. A model entry without CSS → same. Lekalo validates the model in isolation and never sees CSS.

Live output

validated default profile v1.0.0: 23 rules, 0 errors, 0 warnings, 0 info
validated strict profile v1.0.0: 23 rules, 0 errors, 0 warnings, 0 info
lock checked sha256:bc4dbad9… resolver 1.0.0

142 definitions (31 scalar, 18 command, 18 effect, 17 endpoint, 12 query, 10 entity, 9 policy, 9 scenario, 7 enum, 6 event, 3 target-binding, 2 value-object) across five modules: users, blog, comments, themes, design. The parity test: 5 tests, 55 assertions, green.

Wake up

  • The model now describes the design layer too. The vocabulary has

5 modules.

  • The unit of modeling is an identity and a role, not a color. CSS

remains the single source of truth for bytes.

  • The grammar has guts: snake_case values and no empty applies_to.

Bisection and analogy can rescue both mistakes.

  • Always verify the digest recipe against a known-good pin.

Next part: blocks. Grid, section, form, nav, footer. First as a block matrix in the documentation and an architecture test, entering the model only once the vocabulary crystallizes.

Sources

  • Lekalo: the project repository (product 0.1.31, authorization #25)
  • docs/lekalo-model.md: model documentation, including the design section and the model_ref.ir_digest refresh recipe
  • lekalo/modules/design/*.yaml: the Design module semantic model (7 definitions)
  • tests/Integration/DesignModelParityTest.php: the parity guard (5 tests)
  • Part 9.1, themes enter the model: the first time the pinned-digest recipe appeared
  • Part 9.2, themes get routes: endpoint bindings for themes

Comments (0)

No comments yet — be the first to react.

Reader questions (0)

No questions yet — be the first to ask.

Stuck on something in this article? Ask below. Your name is shown publicly; your email is never stored. A question appears here once a moderator approves it.