Expression Language Requirements¶
Note
What the shell needs from the Tesserae Expression Language (TEL). The shell drives TEL from these needs; TEL does not depend on the shell. This note is the shell's side only. TEL's own grammar and design live in the TEL project.
Purpose and Scope¶
TEL evaluates expressions written in shell files, which are written in TDL (ADR-0014 Shell File Language): an expression sits in a <| ... |> slot on one line, and in TDL it needs no quotes (the slot was written with double braces until TDL 0.2; TDL Language > Punctuation). The slot holds values bound to module data. TEL evaluates expressions (values) only. TDL owns structure: its own If, Else and For ... In ... Key blocks decide whether an entry exists and how many copies there are, and the shell's model builder evaluates a condition or iterable through TEL and rebuilds that branch or entry (D11, ADR-0014 Shell File Language > Decisions on the Open Items (2026-10-30)). T3 and T8 below, from 2026-10-25, first gave TEL structure; D11 narrowed them to expression-level conditionals and comprehensions. Python is the front-end for everything TEL should not do: heavy calculation, terminal and system access (ADR-0007 Shell UI Layer > View format: a full expression language, and Python as an equal front-end (2026-10-25)).
Requirements from the Shell¶
| # | Requirement | Source |
|---|---|---|
| T1 | Independent library. Pure Python, installed like any library. It imports neither the shell, tre nor Tesserae UI. | ADR-0008 Tesserae Expression Language |
| T2 | Safe. Evaluates expressions (values) only. No file, process, network or system access, no eval, no attribute escape. Limits on steps, size and repeated or powered values, so a bad expression is an error and never a hang. |
Runs from a configuration file |
| T3 | Values, one language. Values (a number, text or colour), including an expression-level conditional (a if c else b). Structure (whether an entry exists, how many copies) is TDL's If and For, not TEL's; the shell evaluates the condition or iterable through TEL (narrowed 2026-10-30 by D11; first decided 2026-10-25 as "TEL owns both"). |
Expression Languages for YAML > What the shell needs from it; ADR-0014 Shell File Language > Conditions and Repeats (Decided) |
| T4 | Live. Compile once, evaluate many times. The caller can re-run an expression when an input changes. | Clock, battery, volume change while the shell runs |
| T5 | Name tracking. After evaluation the caller can ask which names the expression read, so only expressions whose inputs changed are re-run. The name lookup is a plug-in point the caller supplies (a scope), so TEL needs no reactive types of its own. | Python is never in layout or paint (Vault Reference > Layering principle) |
| T6 | Positions. Every error carries file, line and column, with an origin the caller supplies so a column inside a <\| \|> slot maps to the file. T17 adds the slot's origin from the TDL parser. |
Vault Reference > Layering principle |
| T7 | Same result from Python. The language has a Python form, so a shell written in Python builds the same tree as one written in TDL. | Goals and Non-Goals G1 |
| T8 | Expression-level conditionals and comprehensions. A conditional that yields a value, and a comprehension that builds a list value from a list (workspaces, tray items), inside one expression. A conditional entry (If) and a repeated entry (For) are TDL's, not TEL's; the {if condition, a, b} form is dropped (narrowed 2026-10-30 by D11). |
Maintainer, 2026-10-25; D11 |
| T9 | Values the renderer accepts. Results match types tre accepts. Conversions (for example HEX to RGBA) are the shell's; TEL returns plain values. | ADR-0007 Shell UI Layer > Module data reaches the view through shell entry points (2026-10-25) |
| T10 | Versioned. A file can say which language version it uses, so later changes do not break old files. | The metadata block carries TDL: and the minimum TEL: version already (TDL Language > The Metadata Block) |
| T11 | Python 3.14 or later, no heavy dependencies. | ADR-0007 Shell UI Layer |
| T12 | Testable headless. Parse and evaluate without a display. | Vault Reference > Design completeness checklist |
| T13 | Standalone. Anyone can use TEL in plain data files (YAML, or TDL) by importing its parser in a Python script, with no shell and no Tesserae UI. | ADR-0008 Tesserae Expression Language |
| T15 | Expression language only. TEL has no statements, handlers or event handling; the shell does all of that and may use TEL to evaluate argument expressions at event time. If the shell puts an event name in the scope it supplies, TEL treats it as an ordinary name. Confirmed by the maintainer, 2026-10-26 (told to tess-el; tess-el records it as its D10, replacing D2 and D5). |
ADR-0008 Tesserae Expression Language |
| T16 | Compile off the loop. Compiling an expression is a self-contained computation: it takes its input and returns the compiled result, holding no state shared with other calls, so the shell can compile on a worker thread and hand the result to the loop. | Maintainer, 2026-10-28; Hot Reload |
| T17 | Origin of each slot (accepted 2026-10-31; TEL confirms it already works). The TDL parser tells TEL where each <\| \|> slot starts, as an Origin: file, line and column, 1-based. TEL adds the position inside the expression to it, so a TEL error points to the right place in the file and the shell does no offset arithmetic. The slot is on one line, so the column is a plain offset. TEL already takes an expression or a template with an Origin(file, line, column) (TEL project docs/language.md section 8 and src/tel/origin.py, read 2026-10-29); this item confirms the shell relies on it. Accepted 2026-10-31. The TDL parser also cuts each slot out of the file by the slot-end rule of TDL Language (D54) and gives TEL only the inner text, so TEL's template scanner is not used for shell files. |
ADR-0014 Shell File Language > Consequences; Validation and Errors |
| T18 | Child scope for a loop body (accepted 2026-10-31; TEL confirms a caller-built scope works). TEL accepts a child scope that adds the name a TDL For loop binds (for example item) for the body only, on top of the scope the caller supplies. The name is visible to expressions inside the body and nowhere else, and name tracking (T5) still reports the names read, including names read through the parent scope. Accepted 2026-10-31. |
ADR-0014 Shell File Language > Conditions and Repeats (Decided) |
| T19 | Question-mark conditional (accepted by TEL; released in TEL 0.1.0, 2026-11-02). TEL accepts cond ? a : b as another spelling of a if cond else b, so a style value reads Color: <\| hovered ? "#1e1e2e" : "#313244" \|>. The existing a if c else b stays. TEL parses with Python's ast (TEL project docs/language.md, section 4), and ? is not Python, so this needs a read-time rewrite before the parse that skips strings and leaves slices, dict displays and : in f-strings alone; the cost and whether it fits TEL's whitelist principle are the TEL project's to judge. Without it the same value is Color: <\| "#313244" if not hovered else "#1e1e2e" \|>, which works today. |
Maintainer, 2026-10-29; ADR-0014 Shell File Language > Open Items |
| T20 | Name tree in the scope (accepted 2026-10-31; full-path tracking released in TEL 0.1.0, 2026-11-02). The shell puts the file's name tree in the scope it supplies, so an expression reads an element by its dotted path: RootShell.DP1.Top_Bar.Width. Each Name: is an identifier (letters, digits and _, starting with a letter), so the path is ordinary attribute access in TEL and needs no change to TEL's grammar. TEL needs only the existing rules: read-only public attributes, and name tracking (T5) that reports the path that was read so a change re-evaluates the expression. Nothing to build in TEL if the shell supplies the tree as plain objects (T9, T1). |
Maintainer, 2026-10-30; ADR-0014 Shell File Language > Third-Round Decisions (2026-10-30) D39 |
| T14 | Efficient. Much more efficient than Tesserae's expr.py: parse once, cheap re-evaluation, nothing re-run unless an input changed. A target and a benchmark are set in the TEL project. |
Maintainer, 2026-10-25 |
Requests to the TEL Project (T17 to T20)¶
Four rows in the table above (T17 to T20) were accepted by the maintainer on 2026-10-31 and are marked "not yet sent". They come from the TDL decisions of 2026-10-29 and 2026-10-30 (ADR-0014 Shell File Language). In plain words:
| ID | What the shell asks of TEL | Why | Needed? | Likely cost in TEL |
|---|---|---|---|---|
| T17 | When the shell hands TEL a <\| \|> slot, it also says where the slot starts in the file (file, line, column). TEL counts positions from there. |
A mistake inside an expression is then reported at the right line of the TDL file, not "line 1 of the expression". | Yes | Probably none. TEL's own docs describe an Origin(file, line, column) argument for exactly this (TEL project docs/language.md, section 8). To confirm. |
| T18 | A For item In <\| list \|> loop adds one name (item) that the expressions inside the loop body can read, and no expression outside it. TEL keeps reporting which names an expression read. |
Without it, a repeated entry cannot refer to its own list item. | Yes | Small or none: TEL already evaluates against a scope the caller supplies; the shell can build a scope with the extra name. To confirm that name tracking still sees the parent's names. |
| T19 | TEL also accepts cond ? a : b as another spelling of its existing a if cond else b, so a style value reads Color: <\| hovered ? "#1e1e2e" : "#313244" \|>. |
You said supporting it "would be great". It is a convenience; the shell works without it. | No, optional | Real: TEL reads expressions with Python's own parser, and ? is not Python, so TEL would have to rewrite the text before parsing. TEL's call. |
| T20 | The shell puts the file's tree of names into the scope, so an expression can read another element by its path: RootShell.DP1.Top_Bar.Width. |
It gives expressions direct access to other elements of the file (D39). | Yes (a shell feature) | None in TEL's grammar: each Name: is an identifier, so the path is ordinary attribute access. The shell supplies the tree as plain objects. |
Status: the maintainer accepted all four on 2026-10-31 (T19 as an optional request). The shell session sent the tess-el session four questions at the maintainer's instruction and got answers the same day, recorded below.
TEL's Answers (2026-10-31)¶
The tess-el session answered over the mailbox, checked against TEL's code and docs (a peer's claim is a lead; the shell checked evaluate_tracked, lookup, names in src/tel and D13 and D14 in the TEL project's docs/decisions.md). The answers are information; what they change in the shell's design is below.
| ID | TEL's answer | What it means for the shell |
|---|---|---|
| T17 | Yes. Origin(file, line, column) is 1-based and is the start of the text passed. An error reports the file, line and column in the host file (Origin("A.tdl", 40, 17) and an unknown name reported A.tdl:40:39). Columns count characters. A syntax error's column is where Python reports it, sometimes the start of the text. |
Nothing to build. The parser passes each slot's inner text and its start. A syntax error may point at the slot start; the error text must say so. |
| T18 | Yes. A scope is any object with lookup(name) (raises KeyError) and an optional names(). The shell builds a child scope per evaluation; the compiled expression is shared and keeps no state. evaluate_tracked lists the names asked of the scope, including names the parent answered and the loop name. |
The shell builds one child scope per For entry. TEL does not know which names came from the child: the shell removes the loop name from the dependencies it records. |
| T19 | Accepted and built in the TEL project (its decisions S to W, 2026-10-31; issue #24; src/tel/_ternary.py), local and not yet released. It is a read-time rewrite into the same tree, so the whitelist, evaluator and tracker are unchanged. ?: binds looser than or, is right-associative and is allowed inside f-string fields; mixing ?: with if/else without brackets is refused; the language version stays 0.1. Built cost, from TEL's documentation: an expression that uses it compiles about 2.1 to 2.9 times slower (10 to 22 µs more), text without a ? is unchanged, and evaluation and memory are the same; TEL's estimate is 10 to 20 ms at load for a thousand such expressions. The 4x of the earlier spike run is superseded. |
Available. A style value can read Color: <\| hovered ? "#1e1e2e" : "#313244" \|> once a TEL release carries it; the TEL: pin names that release. |
| T20 | Attribute access on a caller-supplied plain-object tree works, read-only; a property is read too (it runs the host's code). A callable attribute is an error, and a name or attribute starting with _ is refused. Full-path tracking was built locally and tested on the maintainer's instruction (2026-10-31) and is in the TEL 0.1.0 release (2026-11-02). evaluate_tracked(scope) returns Tracked(value, reads), where reads is a set of paths: a bare name or a whole attribute chain on a name (RootShell.DP1.Top_Bar.Width), not its prefixes. Tracked.names gives the top-level names, and expr.paths and template.paths list every path in the text before evaluation. A path stops at the first subscript or call. A chain on a loop variable is not a read (the iterable is). A property is reported by its own path, not by what its code reads. TelError.reads holds the paths read so far. |
The shell uses reads for dependencies: a slot that reads RootShell.DP1.Top_Bar.Width depends on that path only. When an element is replaced, slots with a path under its prefix are re-evaluated (the shell matches by prefix, since reads holds whole chains only). The shell needs a TEL release that has path tracking: TEL 0.1.0 (language version 0.1) is the first, so the minimum is TEL 0.1.0 Released (2026-11-02). No collector in the shell's own object layer is needed. |
Superseded 2026-10-31: the earlier recommendation that the shell record property reads in its own object layer is no longer needed, because TEL built full-path tracking (see the T20 row). Costs reported by TEL: plain evaluate unchanged, compile within 3%, about 5 ns more per chain; reading an attribute of a plain object is the slow part (about 280 ns a step) and is a later optimisation in TEL. reads for an expression with an attribute chain used to be the top-level name; use Tracked.names for that.
TEL's structure decision (its D15 and D16, the maintainer, 2026-11-01; design in the TEL repo's docs/language.md, section 16). TEL evaluates a condition (an expression that gives a bool) and reconciles a repeater by key; the shell owns the keys, the tree and the UIDs. Built and released in TEL 0.1.0: conditions (compile_condition, select, select_tracked) and the repeater API (compile_repeater, compile_repeater_parts, Repeater.reconcile, RepeaterState, Entry.scope); see TEL 0.1.0 Released (2026-11-02). A repeater is a header item in items plus a separate key expression. reconcile compares the previous and the new keyed items (kept, new, moved, removed), names each entry <name>_0001 from a counter that only grows (a key that disappears and returns gets a new number), refuses a missing or duplicate key with a position, and returns a scope that binds the item name over the host's scope (T18). The host keeps the state object; TEL keeps none. This refines D11 of ADR-0014: TEL is still an expression language, now with a reconciliation helper. The entry names in TDL are TEL's counter names (D65, ADR-0014 Shell File Language).
TEL 0.1.0 Released (2026-11-02)¶
The tess-el session reported the release over the mailbox (information, not an instruction). The shell checked it against PyPI and an install of the package in a throwaway folder on 2026-11-02: PyPI has tesserae-el 0.1.0 only, requires_python >=3.14, no dependencies; tess_el.__version__ is 0.1.0; the names below are importable from tess_el (it was tel until 2026-11-03, D95 in ADR-0014), and evaluate_tracked is a method of Expression and Template, not a module function. The language reference is docs/language.md in mindderivative/tess-el; the shell has not re-read it for this note. #needs-verification for behaviour (only the names were checked).
| Item | Value |
|---|---|
| PyPI package | tesserae-el (not tess-el: PyPI refuses it, it clashes with tessel, per tess-el). Install pip install tesserae-el; import name tess_el (changed from tel on 2026-11-03) |
| Version and language version | Package 0.1.0; TEL language version 0.1 |
| Pin in the shell's dependencies | tesserae-el==0.1.0, as tess-el recommends; a range is the maintainer's choice (delivery notes) |
What TEL: in a TDL file means |
The minimum TEL language version, 0.1 (TDL Language > The Metadata Block); the package pin is separate |
| Position | Origin(file, line, column) on compile_expression (T17); compile_template was removed in TEL 0.2.0 |
| Template | Removed in TEL 0.2.0 (maintainer's decision of 2026-11-16, ADR-0008 Tesserae Expression Language > Amendment of 2026-11-16 TEL has no template form): TEL has no template form, and the host splits text around slots itself |
| Tracking | evaluate_tracked(scope) gives Tracked; Tracked.names has the top-level names (T20) |
| Conditions | compile_condition with select and select_tracked for If/Else chains (D64) |
| Repeats | compile_repeater_parts(names, items, key=, name=, names_origin=, items_origin=, key_origin=) takes the For slots separately; compile_repeater takes one item in items header; Repeater.reconcile(scope, RepeaterState) returns entries named <name>_0001 onward (never reused) with status new, kept, moved (fewest) or removed (D65); Entry.scope(parent) is the children's scope, and reads through the item are reported as written (for example w.title), which the shell re-bases |
| Python form (P5) | fill, literal (text with $name placeholders, each value a checked literal) and Expression.canonical (fill_template and Template.canonical were removed in 0.2.0) to compare two spellings. The tree builder and the parity test against the TDL parser stay the shell's |
?: |
Accepted as a second spelling of a if cond else b (T19) |
TEL 0.1.1 followed on PyPI the same day (reported by tess-el, 2026-11-02, information only; the shell has not run its tests against it): the same language (0.1) and the same API, with one change that can touch the shell. A repeater Item and Entry are now tuples (index, key, value, bindings, and for an entry name, status). Attribute access is unchanged, they can be indexed, unpacked and compared by value, and they are not hashable (bindings is a dict), so the binder must not put them in a set or use them as dictionary keys. They stay immutable and cannot be pickled. items() is about 14% faster, reconcile() about 9%. The minimum is now tesserae-el>=0.1.2, the first release that imports as tess_el (published, checked 2026-11-03); 0.1.1 and earlier import as tel (Roadmap > Working Mode: Fluid Dependencies). The PyPI version was checked on 2026-11-02: 0.1.1 is the latest.
Behaviour that limits the shell's scope design (reported by tess-el, not yet tested by the shell):
- A host object inside a list, tuple or dict is carried, but
sum,min,max,sorted,any,all,set,dict,str,==,in, f-strings,.indexand.countover a container that holds one are refused withvalue-not-plain. Sosorted(host_list)is an error; expressions read attributes, index,lenand loop instead. The module and surface trees the shell puts in the scope must stay plain objects, and aForover a list of host objects needs the item read by attribute. - A repeater key that is a bool, float or None is refused; keys are int, str or tuples of those. The shell's default key and any
Key:slot must give one of those (ADR-0014 Shell File Language > Conditions and Repeats (Decided)).
What Tesserae's expr.py Shows¶
From the local clone (commit 0eda3fe, read 2026-10-25). It already provides the sandbox by ast whitelist (T2), limits (T2), static against reactive expressions (T4, T5), a scope lookup (T5), and positions with a caret in errors (T6). It also parses handlers (short lists of statements); TEL will not (T15). Its gaps for TEL: it imports tesserae.reactive (against T1), and nothing in the module header covers a Python front-end that builds the same tree (T7). TEL is a redesign that starts from expr.py (decided 2026-10-25).
Open Questions¶
- TEL's name: Tesserae Expression Language,
telin code (nowtess_el, 2026-11-03). PyPI:tesserae-expression-language, elsetel(taken on 2026-10-25), elsetess-el. - Redesign or extraction: a redesign starting from
expr.py. - Who owns structure: TDL owns
IfandFor; TEL evaluates expressions (values) only (D11, ADR-0014 Shell File Language > Decisions on the Open Items (2026-10-30); first answered 2026-10-25 as TEL owning both). - TEL's repository and licence: mindderivative/tess-el, MIT (2026-10-25). Local project
~/Projects/pyDev/projects/tess-el. - TEL's PyPI name and first release:
tesserae-el0.1.0, language version 0.1 (released 2026-11-02, reported bytess-el, checked on PyPI). The ongoing release process is the maintainer's. - Statements and events: none in TEL. The maintainer told
tess-elthat TEL is an expression language only and that statements, events and handlers belong to the shell (2026-10-26, T15). Syntax and form are worked out in the TEL project (2026-10-25). - How do the shell and any other TEL user share TEL's releases without blocking each other? Context: the shell is one of several TEL consumers, and a release that the shell needs must not wait on another user's schedule. Recommendation: the shell pins a released
tesserae-elversion and asks for changes through requests the maintainer carries to the TEL project, so no consumer waits on another. - T17 to T20 are accepted requirements from ADR-0014 (maintainer, 2026-10-31). The
tess-elsession answered the shell's four questions on 2026-10-31 (see "TEL's Answers"). No request was filed. - T3 and T8 are narrowed to expression-level conditionals and comprehensions; structure conditions and repeats are TDL's (D11, ADR-0014 Shell File Language > Decisions on the Open Items (2026-10-30)). T17, T18 and T19 are unchanged.
Acceptance Criteria¶
- A TEL expression compiles once and evaluates against a caller-supplied scope.
- After evaluation, the caller can list the names it read.
- (T17, accepted) A TEL error in a slot reports the slot's file line and the column inside the expression, from the
Originthe TDL parser supplied. - (T18, accepted) A name added by a child scope resolves inside the
Forbody and is unknown outside it. - An expression with an error reports file, line and column inside the TDL file.
- An expression that tries file, process or attribute access is refused with a clear error.
- An expression over a limit fails with an error and returns promptly.
- The same shell written in Python and in TDL builds the same tree.
- TEL installs and runs on Python 3.14 with no import of the shell, tre or Tesserae UI.