Skip to content

Validation and Errors

Note

Every problem the shell finds in a file is reported with the file, line and column, says what is wrong and what to write, and goes to the console and the log. Checking runs in stages, from the file's bytes to a running module. At start any error stops the shell; on a reload any error keeps the old state (Process Model and Threading > Lifecycle (proposed)). Decided: file:line:column (Vault Reference > Layering principle), JSON Schema for structure (ADR-0011 JSON Schema for Shell Files), the schema cache (JSON Schema and Editor Support), a bad settings.tdl stops the shell (Settings File). Everything else is proposed with a recommendation.

Purpose and Scope

Behaviour

The Pipeline

flowchart LR
    a[1 Read] --> b[2 Parse]
    b --> c[3 Header]
    c --> d[4 Schema]
    d --> e[5 Semantic checks]
    e --> f[6 Expressions]
    f --> g[7 Modules]
    g --> h[8 Run time]
Stage Checks Tool Position comes from
1. Read The file opens and is UTF-8 (a byte-order mark is allowed and dropped) Standard library The file, line 1
2. Parse TDL syntax; the tree is an ordered list of entries (head, properties, children) that keeps repeated names (D12); it holds only blocks, properties, lists and literal values; <\| \|> slots are kept as text for stage 6 The shell's TDL parser (ADR-0014 Shell File Language) The parser's own positions
3. Header The loader reads the metadata block first, then the root block, which picks the schema (D12). The metadata block is present; TDL: is present with a known version; Name: is present and follows the name rules (letters, digits and _, starting with a letter); the minimum version pins (TEL:, TRE:, Shell:) are met; exactly one root block (Shell, Module, Style, Stylesheet, Theme); the root block agrees with the suffix; UID: well formed The shell The key's or the root block's node
4. Schema The schema picked at stage 3 validates the metadata part and the block part (D12). Types, enums (upper case: Edge: top is refused with a hint to write TOP), required keys, unknown keys (the metadata block's other keys are kept and ignored), value forms (colour, four-sided in the order left, top, right, bottom, size) The schema package, in code (ADR-0020 Validation in Code) The tree node at the error's path
5. Semantic Rules a schema cannot say (below) The shell The node at the offending key or value
6. Expressions TEL compiles; every name it reads is known TEL The slot's Origin (file, line, column) from the parser
7. Modules The .py imports; it holds one Module class; validate_use accepts each use Python The traceback line for the .py; the use's node for a rejected param
8. Run time An expression that fails to evaluate; a module callback that raises; a tre error The shell The node or module that ran
  • Unknown keys are errors, not warnings, to catch typos (decided 2026-10-28). The exception is the metadata block, where other keys are allowed and the shell ignores them (TDL Language > The Metadata Block).
  • Stage 3 errors name the file and say which rule failed: no metadata block, no TDL:, no Name:, a bad Name:, no root block or more than one, or the root block and the suffix disagree (the error names both; the root block is authoritative, TDL Language > The Root Block). The proposed codes and hints (tdl-no-metadata, tdl-no-version, tdl-no-name, tdl-bad-name, tdl-no-root, tdl-many-roots and the others) are in TDL Language > Errors; this note does not copy them. The shell raises the suffix check itself as shell-root-suffix (D91).
  • A key in both places (decided 2026-11-04): a key written as a property and inside the block's Style { } is an error, style-duplicate, naming both positions (Block Reference R2).
  • A feature that is not built yet (decided 2026-11-04, D15): a Bar key that M1 does not build (Auto_Hide, Keyboard, Input_Region and the like) is a warning, so the file stays valid when the feature arrives; Import, other surfaces, If and For are errors with the slug not-built.
  • Version pins in M1 (D16): a missing TEL or TRE pin is not an error in M1, because the M1 sample omits them; a pin that is present is still compared with the installed version.
  • A four-sided value is one number, a list of four or a block of named sides. A list of two or three items is refused at stage 4 with the slug bad-sides. No slug list exists in this note: the convention is a short kebab-case word (unknown-key, name-duplicate), and schema and load errors carry no tdl- prefix, which is for the parser's syntax errors (TDL Language > Errors), so bad-sides follows it. The hint says to write one number, four items (left, top, right, bottom) or named sides, and that CSS orders its sides top, right, bottom, left and accepts two or three (Common Keys and Conventions > For Readers Who Know Other Frameworks).
  • A file that fails stage 2 or 3 is not checked further, because later stages need its data; other files continue. Stage 5 runs only when every file has passed stage 4, because it compares across files (decided 2026-10-28).
  • Stages 1 to 7 run before anything is shown at start, and before anything is applied on a reload (Hot Reload). Stage 8 happens while running.

Parsing

Semantic Checks

Rules a schema cannot say, with the note that owns each:

Rule Owner
A property key appears once in a block; a repeat is an error naming both places (D9; repeated block names are allowed) TDL Language > Punctuation
A name is registered once (one registry for blocks, surface types and modules; a user module overrides a shipped one); a name used as a reference exists Config Discovery and Registry > Names, Common Keys and Conventions > Names and references
No import cycle; every imported file exists Config Discovery and Registry > Discovery
A block head names a registered block, surface type or module; a module's params have the declared types; validate_use accepts them Module File, Module Contract
A token $group.name exists in the active theme Style Schema > Theme tokens
Exclusive_Zone only on Layer: TOP; a Bar resolves to a size above 0 on the axis it is attached along (a Bar that resolves to 0, for example a top Bar with Height: EXPAND and no Max_Height or Min_Height, is not created: a warning names the Bar and says to set Min_Height; the check is at creation and never stops hide, peek, expand or contract of a Bar or Frame strip); a Frame or Panel Margin agrees with the meld rule (a Panel attached to a Frame with a Margin on the sides facing the Frame does not meld, with none it melds; a Frame's Margin adds to its total size) Surface Types > Layers per kind, Bar, Frame, Panel
Names follow the rules (letters, digits and _, starting with a letter); enum values are upper case; the root block agrees with the suffix TDL Language > Names and the Registry, TDL Language > The Root Block
Attach_To resolves; a Panel's target is a surface, a module or a Panel Panel, Popup
Auto_Hide and Reveal_Key are consistent Bar > Auto-hide (decided 2026-10-27)
The Python for a module exists, next to its TDL Module File
Two Monitor blocks do not name the same monitor; a Monitor with no selector is ignored (not an error); the files agree on the monitor rules Shell File > Monitors

A rule belongs to one stage. An unknown key is found by the schema (stage 4), not again by stage 5.

The Error Record

Every finding has the same fields:

Field Meaning
file The path, relative to the config directory when inside it
line, column 1-based; 0 only for a problem with the whole file
severity error, warning or info
rule A short stable slug such as unknown-key or name-duplicate; used in logs and tests, not shown as a number (decided 2026-10-28)
message What is wrong and what to write
hint Optional: the nearest valid names, an example, a link to a note

Printed form, as a compiler prints it, with the offending line and a caret under the column:

Shells/Main_Shell.tdl:12:9: error: unknown style key 'Colour' on bar 'top_bar'
    12 |         Colour: red
       |         ^
    hint: did you mean 'Border_Color'?
  • Nearest names come from difflib.get_close_matches in the standard library. A test on 2026-10-28 gave border_color for the typo colour and for border_colour (lowercase, run before keys were Capitalised; the match is the same on Colour and Border_Colour, to re-run).
  • Say what to write. A message names the wrong thing, then the right form: a colour is "#RRGGBB", "#RRGGBBAA" or rgba(r g b a) (Common Keys and Conventions > Errors).
  • Severity. An error refuses the file or the load. A warning never stops anything (a target that disappeared, a rebuilt registry record, a stale cache). An info is a note (an ignored file, a configured directory overriding the default).

How Many Errors, and in what Order

  • Every error from a stage is reported, sorted by file and line, not only the first, so a user fixes a file in one pass. A cap of 50 per run, then a line saying how many more were found (decided 2026-10-28).
  • Errors from different files at the same stage are all reported. Stages after a failed stage are not run for the files they depend on.

Where it Goes

Place What When
Console (stderr) The printed form, in colour when it is a terminal Always
The log file One record per finding, with file, line, column, rule, severity as fields (Settings File > Log files) Always
A desktop notification A short summary and the first error A failure that stops the shell, or a failed reload; opt-out (decided 2026-10-28, Shell Start and Stop > Accessibility)
The command check The same output, no shell started, exit code 1 on any error On demand (the IPC and CLI note, to write)

What a Failure Does

When Error Warning
Start The shell stops with exit code 1 (Shell Start and Stop > Exit codes) Printed; the shell continues
Reload The old state is kept and the error is reported (Hot Reload) Printed; the new state applies
Stage 8, while running Logged with the node or module; the node shows its fallback, the rest of the shell continues Logged

A bad settings.tdl always stops the shell at start (decided 2026-10-27) and keeps the running settings on a reload.

Configuration

settings.tdl: Validation with Enabled (default true) and the cache location (Settings File). Proposed additions: Max_Errors (default 50) and Notify (default true) in the Validation block. No other key.

Python Contract

A module reports a rejected param by raising ValueError in validate_use (Module Contract); the shell turns it into a stage 7 error at the use's node. A module's runtime exceptions are caught by the shell, logged with the module name and UID, and do not stop others (Process Model and Threading > Failure and recovery). A module can log through ctx.log (Module Context) but does not format shell errors.

Integration

  • The TDL parser (tess_dl), difflib for the nearest key names, and Loguru (Logging with Loguru). No JSON Schema library is loaded (ADR-0020 Validation in Code).
  • Threads: stages 1 to 7 run on the config watcher thread or before the loop at start; the loop only receives a finished result or a finished report (Process Model and Threading > Threads).
  • TEL: the parser tells TEL where each <| |> slot starts as an Origin (file, line, column, 1-based), so TEL errors point into the file and the shell adds no offset itself. A slot is on one line, so no indentation arithmetic is needed. This is the proposed requirement T17 in Expression Language Requirements, not yet sent to the TEL project. #needs-verification

Design

The printed form is plain text and works without colour. No icons, and no emoji (Vault Reference > Writing style).

Accessibility

A plain-text error is readable by a screen reader in a terminal. An error that stops the shell is also sent as a notification so a user who launched it from a menu sees it (Shell Start and Stop).

Performance Budget

  • A changed file costs a parse and a validation in code; the checks are table-driven and take milliseconds at most for a shell of a few hundred entries (to measure, Performance Budgets). There is no validation cache (ADR-0020 Validation in Code).
  • Collecting up to 50 errors adds nothing the user feels; the cap protects the log.

Failure Modes and Recovery

Failure Result
The validator itself fails (a schema that does not compile) A shell error naming the schema; the shell falls back to its own checks of required keys and types (JSON Schema and Editor Support > Failure modes and recovery)
A file is huge or binary Stage 1 error naming the size or the encoding; the size limit is 1 MiB per TDL file (decided 2026-10-28, written for YAML files)
An error cannot be mapped to a node Reported at the nearest parent's line, with the path in the message
Logging is not available The console still gets the error

Open Questions

All seven were answered on 2026-10-28, as recommended.

  1. Unknown keys are errors.
  2. Rule slugs in logs, no numeric codes.
  3. Stop at 50 errors.
  4. A notification for a failed start or reload, opt-out.
  5. A check command (it needs the IPC and CLI note).
  6. A size limit of 1 MiB per TDL file.
  7. Stage 5 only after every file passes stage 4.

Raised by the move to TDL (ADR-0014 Shell File Language), not yet asked:

  1. Should the TDL error list (rule slugs for syntax errors such as an unclosed brace or an unclosed slot) in TDL Language > Errors be accepted as proposed? Context: the list is a proposal and the maintainer has not decided it. Recommendation: accept it as the first list and extend it as real errors appear.

Answered on 2026-10-30 ("Do all as you would recommend", ADR-0014 Shell File Language > Decisions on the Open Items (2026-10-30)):

  • A property key repeated inside one block is an error naming both places (D9).
  • Boolean and null literals, and how unquoted words become numbers, for stage 4 types: the key's declared type decides (D2).
  • Stage 3 reads the metadata block first, then TDL:, then the root block, which picks the schema (D12, with the file-type key replaced by the root block). The error text for each rule is part of the TDL error list in TDL Language > Errors.

Acceptance Criteria

  • A file with a TDL syntax error is reported with file:line:column, and no later stage runs for it.
  • A file with no metadata block, no TDL:, no Name:, or not exactly one root block is refused at stage 3 with an error naming the file; a root block that disagrees with the suffix is an error naming both.
  • A Name: with a - or a leading digit is refused with an error that says which characters are allowed.
  • Edge: top is refused with an error that says enum values are upper case.
  • A Bar that resolves to size 0 on its attached axis is not created and the warning names the Bar and says to set Min_Height; hiding and revealing a Bar is not stopped by this check.
  • Two blocks with the same name in one Children { } load, in positional order (the YAML-era rule that rejected duplicate keys no longer applies).
  • An unknown style key reports its line and column and offers the nearest key.
  • A wrong-typed value reports the types allowed and what to write.
  • A property key repeated in one block is reported as an error naming both places.
  • A file with six deliberate mistakes yields six errors, each at the right line and column (JSON Schema and Editor Support > Acceptance criteria).
  • A module key that names nothing registered reports the nearest names.
  • A TEL error reports the file line and the column inside the expression.
  • At start any error stops the shell with code 1 and nothing opens; on a reload the old state keeps running.
  • A warning never stops the shell.
  • The log record of each finding carries file, line, column, rule and severity.
  • No error is reported twice by two stages.
  • A <| |> slot with an error in its expression reports the file line and the column of the error inside the slot, using the Origin the parser gave TEL.