# Ord semantics Version 0.8.0-draft, 2026-12-01. A companion spec to [Ord specification](Ord_Specification.md), of the same version. The Spec's conventions (S1 to S6) and versioning (S10) apply here, and rule IDs that start with `C`, `L`, `D`, `T` or `F` refer to the Spec. This spec's rules start with `M`. The Spec says how text becomes a tree of nodes and fields. This spec says what that tree means across a workspace: which node a reference points to, what types and states a node has, who owns whom, and what formulas and queries written in files stand for. ## 1. Scope and the line - **M1.** This spec covers what files mean. Two tools that conform to it give a workspace the same graph: the same nodes, owners, types, IDs, states, field values and references, and the same diagnostics from section 10. - **M2.** A rule belongs here when it is about something written in a file that a tool interprets, or something a tool writes into a file. Anything that exists only in a tool, such as an index, a view, completion or a heuristic whose result isn't written, is implementation and outside this spec. - **M3.** These are explicitly implementation-defined, so tools may differ: - how value types are inferred, and outlier warnings; only value forms (L21 to L27, L35) are normative - diagnostics beyond section 10, which use codes outside this spec's letters, e.g. `ord/outlier` - how and when a graph is stored, cached or rebuilt - completion, hover, inlay hints, views, CodeLens and results documents - fold state and other view state, which is never written into the files: a tool keeps it apart, finding a folded node again by its ID or its place in the tree, and a node it can't find stays open - merging and sync - **M86.** **Files, and what they define.** A workspace has three layers: - **The files** are the source of truth: a node has what is written on it (M37). A tool changes a file only to help the person writing it: it writes a one-time formula's result in its place (M85), a type's fields, template and checkbox on a node given the type (M37, M51, M66), and a change to a type's fields on its nodes (M84), and makes the edits the person asks for, such as renaming a node or a field along with what refers to it. - **What the files define**: searches (M60), mirrors (M48) and formulas (M39, M87). They are written in the files and evaluated over the graph, and their results are virtual: an editor shows them where they are defined, and a tool never writes them into a file. They are one layer because they read each other: a query can match a calculated field (`=(total > 42)`), a mirror stands for its source in formulas (M49), and a formula can run a query (M76). - **What is computed from a search's results**: its `footer` setting (M64). It is shown with the results, and nothing else reads it. - **M4.** A **graph builder** reads a workspace (Spec F4) with label syntax (Spec Part 2) and builds the graph as this spec says, and passes the tests with the `graph` option (Appendix A). ## 2. The graph - **M5.** The **workspace** is every Ord and CSV file in it, `.csv` and `.tsv` (CSV mapping V1), its workspace file included (Spec F1, F3, F5; CSV mapping). Files are taken in code point order of their paths relative to the workspace folder. - **M6.** Every node in every file is a **graph node**: each file's root (C14), each node and anonymous node (C13), and each row of a CSV file. A graph node has a file and a position, and: - a **label**: the L19 label for a node Part 2 reads, the Core label for any other node, and none for anonymous nodes - **fields**: a list of (key, value) pairs, from field lines, inline fields and triggers (section 3) - an **owner**, section 4 - **M7.** A field value is a text item, a node item (whose node is a graph node), or a value trigger read from an item (L20). ## 3. Fields - **M8.** A node's fields come from every form a field can take: its field lines (C11), the fields Part 2 reads from its label (D12, `inline` and `embedded` alike), and its CSV cells. Each form adds its values under its key, in the order: label forms first, as written, then field lines in file order. - **M10.** `_label`, `_id`, `_state` and `_mirror` are **single-valued**: a node has at most one value for each, from any form. A second one is the error `M10`. Every other field holds every value it is given, from every form. - **M11.** The **system fields** are `_label`, `_name`, `_types`, `_id`, `_state`, `_tags`, `_link`, `_mirror`, `_result`, `_url`, `_parent`, `_children`, `_file` and `_json`. They are defined by **system field definitions**, field definition nodes (M55) built into every workspace (M53), and their meaning is fixed by this spec. They can't be defined again: a field definition node for one of them is the error `M55.2`. A type lists them as it lists any field definition node (M58). `_result` is the formulas in the label, each an item of a computed field (M39): read in a formula, it is their results, one item each, as `R`. Their results aren't fields of the node: with the label `=({"a": 1})`, `R.a` is 1 and `a` is nothing. Every other key that starts with `_` is reserved (M92). `_name` is the node's label without the tags at its end, its name (M23), read from the label: a node with the label `Send proof #mail #teams` has the name `Send proof`, and `Call #anna about budget #projectX` the name `Call #anna about budget`. A formula in the label (L12) is replaced in the name by its result, written as text: a list as its items joined by `; `, an object in one line (M39), and nothing as nothing, with runs of spaces and tabs made one space. So `Parent =("bad")` has the name `Parent bad`; a formula that fails gives nothing. While a node's own label formulas are evaluated, its name is read as written, without their results, so a label formula that reads its own name, alone or among its siblings' as `=(P.C[N = "Status"])`, isn't a cycle (M44). A node without a label has no name. It can't be written: a `_name` value on a node, in any form, is the error `M11.1`, and is ignored. `_file` is the path of the node's file, relative to the workspace folder, with `/` between folders, as `notes/projects.ord`. It can't be written either: a `_file` value on a node is the error `M11.2`, and is ignored. `_json`, as a file's only line, is the JSON value the file is in the [JSON mapping](JSON_mapping.md) (J19), as `_json:: 5`; nothing in this spec reads it, and in the graph it is a field like any other. - **M12.** The settings of a node of a system type (M53), a type definition, tag definition, field definition node or search node, configure it; they are not data, and their child lines aren't graph data either, except a field definition node written under a `fields` setting (M58). ## 4. Ownership - **M13.** A graph node's owner is the node it is indented under (C9), or, for a node item, the node that has the field (C13). A file's root has no owner. - **M14.** In CSV, a `_parent` cell names the owner of the row. It holds a reference (section 6). Only a file's top-level node can be re-owned this way; a node that has an owner by indentation keeps it, with the warning `M14.1`. `_children` is only what M16 says it is: a `_children` cell is the warning `M14.3`, and is ignored. - **M15.** Ownership never loops. Nodes in a `_parent` loop get the error `M15` and have no owner. - **M16.** A node's `_children` are the nodes it owns: by indentation in file order, then by `_parent` cells in file order. ## 5. Types and IDs - **M17.** A node with the type `_type` (M53) is a **type definition**. It defines the type named by its `name` value, a name (L3): ``` Task +_type name:: task ``` A type definition without a `name` is the warning `M17.3` and defines nothing. A value that isn't a name is the error `M17.1`, and two definitions of one name are the error `M17.2`. - **M18.** A node's **types** are its `_types` values, in order, without repeats. A type without a definition is allowed. - **M20.** A node's **ID** is its `_id` value. It must be a name (L3), with the error `M20.3`, and IDs match ignoring letter case. Two nodes with one ID is the error `M20.1`; both keep it, and references resolve to the first in file order (M5). - **M19.** A type definition's settings are those of `_type` (M53). `color` is how editors show the type, e.g. as a pill: a color name (`red`, `orange`, `yellow`, `green`, `teal`, `blue`, `purple`, `pink`, `brown`, `gray`, `black`, `white`) or `#rrggbb`; or the name of a field, as in `color:: project`, so a node's type shows in the color of its value there: the `color` of the node the value refers to, else a color the editor picks by that node's label, or for a value that refers to no node, by its text. A node without the value shows the type as it would without the setting. A color name is never read as a field's name. - **M59.** A node with the type `_tag` (M53) is a **tag definition** for the tags its `name` values name, without `#`, ignoring letter case, as `Urgent +_tag` with the field lines `name:: urgent` and `color:: red` under it. Each value is a tag as L13 or L29 reads it: it starts with a letter and holds no `]`. A value that isn't is the error `M17.1`, and two tag definitions for one tag are the error `M17.2`. Its settings are those of `_tag`: `color`, a color name or `#rrggbb` that the tag is shown in, and `icon` and `description` (M52). - **M66.** `checkbox:: true` (L27) gives the type's nodes a checkbox: when an editor or a tool gives a node line the type and the node has no state, it adds the trigger `[ ]` (L11) before the line's text, after any list marker (L16), so `Buy milk +todo` becomes `[ ] Buy milk +todo`. A node that has a state keeps it, and a node without one is not an error: a reader doesn't add the trigger, and taking it away again is allowed. - **M51.** A type's `nodes` setting is a **content template**: its node children (C13), with their child lines. When an editor or a tool gives a node the type, on a new node or an existing one, it writes a copy of them under the node, in order, after its other children, with their `_id` fields left out, so each node gets its own content. When a node is given several types at once, their templates follow each other in type order (M18). Field lines under `nodes::` aren't part of the template; a type's fields are written from its `fields` setting (M37). Only adding the type writes the template: a reader never adds it, and a node that already has the type doesn't get it again. ``` Meeting +_type name:: meeting nodes:: Agenda Notes Action items ``` Creating `Weekly sync +meeting`, or adding `+meeting` to an existing `Weekly sync`, writes `Agenda`, `Notes` and `Action items` under it. - **M52.** The `icon` setting of a type, a tag definition, a field definition (M56) or a search node (M60) is an emoji, as in `icon:: 📅`, and its `description` setting is text about it, quoted (C21) when it holds `;`. Both are informative: this spec gives them no meaning, and tools don't check them. An editor may show the icon with the type, tag, field or search, and the description where it is chosen. ### Built-in types (informative) A workspace usually starts with this definition in its workspace file. It is an ordinary type definition, so its fields and settings can be changed like on any type. ``` Task +_type name:: task fields:: due:: ``` Journal nodes, where tools put things for a date, are ordinary nodes found by their ID: `journal-` and the date, such as `Monday 12, 2026 ^journal-2026-10-12` and `October, 2026 ^journal-2026-10`. They have no type. Tools create them when something goes to a date. ## 5a. System types and fields - **M92.** **Reserved names.** What this spec builds in is named with a leading `_`: the system fields (M11), the system types (M53), other than `search`, and the built-in IDs (M95). A name (L3) or key that starts with `_` is **reserved** for them, wherever it is written, and one that names nothing built in is the error `M92`: a field's key, as `_due::` or `[_due:: …]`, a type, as `+_task`, a tag or any part of a nested tag, as `#_draft`, an ID, as `^_x1` (written on a node: a built-in ID is no node's to take), a custom state (M27), a type or tag definition's `name` and a field definition node's `key`. The form is read as written, with the error. Defining a built-in name again is an error of its own: a system type is `M17.2` and a system field `M55.2`. Later versions of this spec may build in more names that start with `_`, so a workspace never uses them for its own. - **M53.** `_type`, `_tag`, `_field` and `search` are **system types**, built into every workspace. This spec defines them, as if these definitions were in the workspace file, and a file that defines one of them is the error `M17.2`. Their color is `white`, so editors show them apart from a workspace's own types. Their settings are local field definitions (M36), and are settings only on their own nodes: on any other node, `name::`, `key::`, `color::` and the others are ordinary fields, and a node that has them without the system type defines nothing. The system field definitions (M11) are built in the same way. ``` Type definition +_type name:: _type color:: white fields:: name:: description:: The name of the type it defines. fields:: description:: The fields of the type's nodes, as field lines or field definition nodes. state:: description:: The type's custom states, each a name with an optional marker and base. color:: description:: A color name, a hex color, or the name of a field whose value gives the color. checkbox:: options:: true; false description:: Whether the type's nodes get a checkbox. nodes:: description:: Nodes copied under a node when it is given the type. icon:: description:: An emoji shown with it. description:: description:: Text about it. Tag definition +_type name:: _tag color:: white fields:: name:: description:: The names of the tags it defines. color:: description:: A color name or a hex color. icon:: description:: An emoji shown with it. description:: description:: Text about it. Field definition +_type name:: _field color:: white fields:: key:: description:: The key of the field it defines. value:: description:: What is written on the nodes of the types that list it: a formula, a one-time formula, or text. valid:: description:: A formula that each value of the field must make true. options:: description:: The values the field is meant to hold, and the types of the nodes it refers to. tags:: options:: true; false description:: Whether the field's options can be written as tags. icon:: description:: An emoji shown with it. description:: description:: Text about it. Search +_type name:: search color:: white fields:: query:: description:: The query, written after `?` (L28): terms joined by spaces for and, and by a bar for or. view:: description:: How the results are shown. fields:: description:: The fields shown for each result. sort:: description:: The order of the results. group:: description:: The field the results are grouped by. footer:: description:: What is shown under the results. icon:: description:: An emoji shown with it. description:: description:: Text about it. Label +_field key:: _label description:: The node's label, its line without the forms that are not part of it. Name +_field key:: _name description:: The node's label without the tags at its end (M23), read from the label; it can't be written. Types +_field key:: _types description:: The node's types. ID +_field key:: _id description:: The node's ID, a name that references can use. State +_field key:: _state description:: The node's state, a built-in state or a custom state of its types. Tags +_field key:: _tags description:: The node's tags. Link +_field key:: _link description:: A reference to a node, by its label, its ID or both. Mirror +_field key:: _mirror description:: The node that this node is a mirror of, its source. Result +_field key:: _result description:: The formulas in a label, evaluated where they are written; read in a formula, their results. A formula in a field's value is a formula item of that field (M39). URL +_field key:: _url description:: A URL or a path. Parent +_field key:: _parent description:: The node's owner: the node it is indented under, or the node a CSV cell names. Children +_field key:: _children description:: The nodes it owns, in order: by indentation, then by CSV `_parent` cells. File +_field key:: _file description:: The path of the node's file, relative to the workspace folder; it can't be written. JSON +_field key:: _json description:: As a file's only line, the JSON value the file is in the JSON mapping (J19); nothing else reads it. ``` - **M88.** **The workspace's name.** A `workspace` field line in the workspace file (Spec F5), at any depth, under a node or not, holds the workspace's own settings as field lines under it: `name`, the workspace's **name**, which an editor shows for the workspace in place of its folder's name; `icon`, an emoji; and `description`, text about it. `icon` and `description` are informative, as in M52. As in `workspace::` with `name:: Pontus's notes` and `icon:: 📒` under it. Only the first `workspace` field line in the file counts. A workspace without a name has none, and an editor shows its folder's. In any other file, `workspace` is an ordinary field. `_workspace` is no system type (before 0.9.0-draft it was, and a node with it named the workspace), so `+_workspace` is the error `M92`. - **M89.** **Workspace properties.** A `pinned files`, `pinned nodes` or `pinned searches` field line in the workspace file, at any depth, under a node or not, lists what an editor shows first, as pinned. Their values are written as child lines under the field line, one value each (C13), as in `pinned files::` with `notes/projects.ord` and `journal.ord` under it. A `pinned files` value is a file's path, relative to the workspace folder, with `/` between folders; a `pinned nodes` value is a reference (M21), as `[[^apollo]]` or `[[Project Apollo]]`; a `pinned searches` value is a query, as written after `?` in a search (M60), as `+task !done`. The values of every such field in the file count, in file order, and one given twice counts once. They are not settings: they configure nothing else, and the node they are written on keeps them as ordinary fields. A value that names no file or no node is left out, without a diagnostic. A value's node item is no query result (Queries and Views) and no suggestion for a reference or a mirror: it only says what is pinned. In any other file, `pinned files`, `pinned nodes` and `pinned searches` are ordinary fields. A `csv` field line there holds the settings of the workspace's CSV files, their label column and delimiter ([CSV mapping](CSV_mapping.md) V16). ## 6. References - **M21.** A **reference** points from a field value to a graph node. These values are references: - a link (L10), in any field - a plain text value of the `_link` field - a plain text value of the `_mirror` field, read as inside `[[` and `]]` (L10), and a mirror value (L31) - a plain text value of a reference field (M24), quoted or not in a field line, and unquoted in an inline field (L5) - a `_parent` cell (M14) - **M22.** A reference names a node by ID, by label, or both, as in L10. A plain text value that is a reference (M21), in a field line, an inline field or a cell, is read as inside `[[` and `]]`, as a `_mirror` value is: `follows:: Send proof^p1` names the node by ID and label, as `[[Send proof^p1]]` does, and `follows:: ^p1` by ID alone. `$node()` (M74) reads its text so too. It resolves: - by ID alone (`^x1`, or ID and label): the node with that ID. If none has it, the error `M22.1`. The label is never a fallback; when it no longer matches the node (M23), the warning `M22.2`. - by label alone (`"Anna Smith"`, or a quoted link): the node with that label, as in M23. - by text that could be either (`[[anna]]`, `client:: acme`): the node with that ID, or else the node with that label. When it is one node's ID and another node's label, the ID wins, with the warning `M22.3`. - **M23.** A label matches a node when their names are equal, ignoring spaces and tabs at either end and letter case. A label's **name** is the label without its formatting ([Ord specification](Ord_Specification.md) L34), so `[[Ship v2]]` names `Ship **v2**`, with each link (L14) in it written as its text: its label without an `^id`, the ID with its `^` for a link by ID alone, or its path, so `[[See Anna now]]` names `See [[Anna^a1]] now`, and without the tags (L13) at its end: each tag followed only by spaces, tabs and other tags is removed, with the spaces and tabs before it. Tags elsewhere are part of the name, and a label that is only tags is its own name. So `Buy milk #urgent` is named `Buy milk`, and `[[Buy milk]]`, `[[Buy milk #urgent]]` and `[[Buy milk^x1]]` name it; `Call #anna about budget #projectX` is named `Call #anna about budget`, which `[[Call about budget]]` doesn't match. A label with formulas (L12) matches by its name as written and by its name with each formula's result in its place (M11): `Parent =("bad")` matches both `[[Parent =("bad")]]` and `[[Parent bad]]`. The results are those of the last evaluation; when they change a name, references are resolved again and the formulas evaluated again, at most twice, so a name that depends on the references it resolves settles. An editor that writes a reference to a node writes its name. Letter case is compared by mapping both to lowercase with Unicode's default case mapping (not locale-specific); there is no other normalization, so `é` written as one character or as `e` and a combining accent are different labels. In a reference field (M24), only nodes of its types match. No match is the warning `M23.1`; several matches is the warning `M23.2`, and the reference doesn't resolve. - **M24.** A field is a **reference field** when its field definition, a type's (M36) or a field definition node (M55), has an `options` setting (M46) that names one or more types, each as an item `+name`, as in `options:: +person` or `options:: +person; +company`. A plain value of a reference field is then a reference to a node of those types, unless it equals one of the setting's other options, ignoring letter case, which stays text: with `options:: nobody; +person`, `owner:: nobody` is text and `owner:: Anna` a reference. Any other field's plain values are text, even when they name a node; a tool may suggest adding `options:: +name`, but doesn't resolve them. - **M25.** References may form cycles. They are links, not ownership or dependencies. ## 6a. Mirrors - **M48.** A node with a `_mirror` field, from a mirror line `@ Label` ([Ord specification](Ord_Specification.md) L30), an inline field or a field line, is a **mirror** of the node its reference resolves to (M22), its **source**. A mirror adds nothing to its source: the source keeps its one owner (M13), its fields and its children. The mirror is a graph node of its own, owned where it is written, with an empty label. A mirror whose reference doesn't resolve has that reference's diagnostic and no source. A mirror can't itself be a source, since it has no label or ID to be named by. A reference that ends in an Ord or CSV file's extension, `.ord`, `.txt`, `.csv` or `.tsv`, ignoring letter case, is a **path** instead: the mirror's source is that file's root node (M13), so it shows the whole file, its top-level nodes as the source's children. The path is resolved as a path link is (L14), relative to the folder of the file the mirror is in, so `@ plan.ord` is a file beside it, `@ notes/plan.ord` one in a folder under it and `@ ../plan.ord` one in the folder above; the extension is required. A path that names no file of the workspace is the warning `M48.1`, and the mirror has no source. A file mirrored in itself, at any depth, is under its own source (M50.1). An editor shows the file's name in the mirror's place, and edits through it change the file's lines; it suggests the workspace's other files, by their paths, when `@` is typed. - **M49.** **A mirror stands for its source.** A mirror that is a field's node item (C13) is a reference (M21) from the field's node to the source, so `attendees::` with `@ Anna Smith` under it means what `attendees:: @Anna Smith` and `attendees:: [[Anna Smith]]` do, and a reference field's options (M24, M46) check the source. A mirror that is a child stands for its source in its owner's `_children` (M16), in formulas (M41) too: a project's `$sum(_children.hours)` counts the tasks it mirrors. A source mirrored more than once under one owner is one child, at its first place. - **M50.** A mirror under its own source, at any depth, is the warning `M50.1`. It stands for nothing in `_children`, and an editor shows the source's line but doesn't unfold it. Lines under a mirror are the warning `M50.2`, since a mirror's children are its source's. They are kept as the mirror's own, and an editor may offer to move them into the source. - **M95.** **Built-in IDs.** These IDs name **built-in nodes**, which the tool makes from the workspace as it is now: `_index`, every file of the workspace, with its node count; `_workspace`, the workspace itself, its `workspace` settings (M88), types, tags and fields with how many nodes use them and where each is defined, workspace formulas (M41), pins (M89), the journal's and CSV files' settings, and totals; `_built-in`, what this spec builds in: the system types (M53) and fields (M11) with their aliases (M41), the built-in states (M26), the built-in IDs and Ord's functions; `_settings`, the editor's settings, each with its value and where it comes from; `_problems`, every error and warning, by file; and `_unresolved`, the references, mirrors and paths that name nothing (M22.1, M23.1, M23.2, M48.1). A reference to one, as `[[^_index]]` or `@ ^_index`, resolves without a diagnostic. A built-in node is in no file: a mirror of it shows the lines the tool makes for it, which are virtual (M86) and read-only, never written into a file, no query result (Queries and Views) and no suggestion for a reference. How each is laid out is the tool's. `_today` is today's day node in the journal, `^journal-` and today's date, when there is one, so `@ ^_today` mirrors it as any node is mirrored; when there is none, it names nothing, without a diagnostic. Written on a node, a built-in ID is the error `M92`. ## 7. States - **M26.** A node's **state** is its single `_state` value (M10), from its trigger (L11) or a field. It is a **built-in state**, `new`, `in-progress`, `waiting` or `done`, or a custom state (M27): one that a custom marker stands for (M29), or else the last in type order (M18) of the node's types that defines it. A value that is none of these is the warning `M26`, and the node keeps it as its state, with no base. - **M27.** A type's `state` setting defines its **custom states**: `|`-separated parts, each a name (L3), an optional marker in brackets, and an optional `>` and **base**, a built-in state, as in `triage [t] > new | review [r] > in-progress | shipped > done | someday`. Spaces and tabs around the parts don't count. A part in another form, with a base that isn't a built-in state, or with the name of a built-in state or of a custom state the type already has, is the warning `M27.1`, and the part is left out. - **M28.** A custom state's marker is one character. It can't be a built-in marker (` `, `-`, `?`, `x`), with the warning `M28.1`, and a marker can belong to only one custom state across all types, with the warning `M28.2` on each later one. Such a custom state has no marker. - **M29.** A custom marker stands for the custom state it belongs to, on any node: `[r] Fix login` has the state `review`. A marker no custom state has (L11) gives the node no state. - **M30.** A node's **base** is its state's base. A built-in state is its own base. A custom state without a base, and a state that is the warning `M26`, give the node no base. - **M31.** `done` is true for a node exactly when its base is `done`. ## 8. Field definitions and formulas Tests in Appendix A cover each rule of this section. The rules run from definitions, through what tools write, options and tags, and formulas, to the function library and one-time formulas. - **M36.** A type definition's `fields` setting holds **field definitions**: **local field definitions**, its field lines under its anonymous node (C13), and field definition nodes (M55, M58). The two are one thing written two ways, with the same settings (M56), and differ only in scope: a local definition applies on the type's nodes, a field definition node on every node (M57). A local definition's key is the field it defines, what is written after it on its line is its `value` setting, and its child field lines are its other settings. A formula must start on the key's line (M87). A child field line whose key isn't a setting (M56) is a **nested field definition**: it defines a field written under that field, as a field line of its anonymous node (C13), and has the same settings and nested field definitions of its own, at any depth. When several of a node's types define the same key, the last of them in type order (M18) wins: its definition applies, whole, with its settings, and the others' don't, none of their settings merged in. So with `+task +bug`, where both define `priority`, `+bug`'s `options` and `value` apply. A field definition node applies only where none of the node's types defines the key (M57). The same holds wherever a node's types disagree: the last type's custom state (M26), calculated field (M87) and tag field (M47). - **M55.** A node with the type `_field` (M53) is a **field definition node**. It defines the field whose key is its `key` value, for the whole workspace: ``` Priority +_field key:: priority options:: high; medium; low tags:: true ``` A field definition node without a `key` is the warning `M55.3` and defines nothing. Where this spec matches a field to its definition, keys match ignoring letter case, as labels do (M23); the Core keeps keys as written, so `Due` and `due` on one node are still two fields. Two field definition nodes for one key are the error `M55.1`, and one for a system field (M11) the error `M55.2`. - **M56.** A field definition's settings, local or a node, are `value`, `valid`, `options` and `tags`, as in M37 to M47 and, for a calculated field, M87, and `icon` and `description`, as in M52. A field definition node has them as field lines, besides its `key`. - **M57.** A field definition node applies on every node (M36), so with the definition above, `Crash #high` has `priority:: high` whatever its types. Only its `value` (M37) is limited: it is written on the nodes of the types that list it (M58), or for a formula calculated on them (M87), since only they are meant to have the field. - **M58.** A type lists a field definition node in its `fields` setting in either of two ways: - a field line with its key and no value or child lines. A value or child lines there are the error `M58.1` and are left out, since a type can't change a field definition node. The exception is a `~expr` value for `_id` (M37). So a type can't calculate a system field: `_label:: =(…)` under `fields::` is this error too. - the field definition node itself, written under `fields::` as a node item (C13). It is read there although it is under a setting (M12), and defines its field for the whole workspace, as it would anywhere else. For a key that no field definition node defines, a type defines its own field (M36). ``` Task +_type name:: task fields:: Owner +_field key:: owner options:: +person priority:: due:: ``` Here `owner` and `priority` are defined for the whole workspace, and `due` only for `task`. - **M37.** **A type's fields are written on its nodes.** When an editor or a tool gives a node a type, on a new node or an existing one, it writes a field line for each of the type's field definitions (M36, M58), other than calculated fields (M87), whose key the node doesn't have, where C48 puts a new field, in definition order. When a node has several types, each type's fields follow in type order (M18), and a key that several of them define is written once, where the first of them puts it, from the definition that applies (M36), the last type's. The line holds the definition's `value` as written: `~expr` as a one-time formula, which is then replaced with its result (M85), any other value as text, and no value as `key::`. Nested field definitions (M36) are written as field lines under their field, the same way. `_id` isn't written as a field line: a `~expr` for it gives each node of the type without an ID one, once: the result, when it is a name (L3) that no other node has as its ID, else an ID the tool makes up. A reader never gives a node a field or a value from its types, except a calculated field (M87): a node has what is written on it, and a type's `value` is what tools write. ``` Invoice +_type name:: invoice fields:: amount:: vat:: =(amount * 0.25) status:: open ``` Given the type, `March +invoice` becomes the lines below. `vat` isn't written: it is calculated (M87). ``` March +invoice amount:: status:: open ``` - **M84.** **A type definition edits its nodes.** A change to a type's field definitions is a change to its nodes, as an edit through a mirror is a change to its source (M48), except that it is written into each node's file. When a type gains a field definition, nested ones included, tools write it on each node of the type that doesn't have its key, as M37 does. When a field definition's `value` changes, tools rewrite the field on each node whose value is still the old one as written, ignoring spaces and tabs at either end, and leave it where the node writes another value: that node has changed it. A field definition renamed in place, its key changed and nothing else in the type's fields, renames the field on each node that has it, keeping the node's value. A field definition that is removed leaves its fields on the nodes as they are. A change reaches only the nodes the definition applies to (M36): on a node with a later type that defines the same key, the field is that type's, and stays as it is. A calculated field (M87) isn't written, so a change to its formula changes no file. When a `value` becomes a formula, tools remove the field from each node whose value is still the old one as written; a node that writes another value has the error `M87.1` until it is removed. When a formula becomes a plain value or none, tools write the field on each node as M37 does. Tools write these edits once the change to the type definition is done, not while it is being typed, as one edit of all the files, so one undo takes them back. - **M46.** An `options` setting lists the values a field is meant to hold, as its items or as the labels of its node items without child lines (C13), in order. An item `+name` names a type instead, whose nodes the field refers to (M24); it is not an option. A value written for the field, other than a formula, on a node the definition applies to (M36), or the result of a calculated field (M87), that equals none of the options of the definition that applies (M36), ignoring letter case, is the warning `M46`, and the value stays. On a reference field such a value is a reference instead, and not the warning. Options say how a field is meant to be used, not its value type, and tools offer them first when a value is typed. - **M47.** A `tags` setting of `true` (L27) lets the field's options (M46) be written as tags. On a node the definition applies to (M36), a tag that equals one of the options, ignoring letter case, is a value of that field instead, spelled as the option is, and the node doesn't have that tag: with `options:: bug; feature` and `tags:: true` on the `issue type` field, `Crash +issue #bug` has `issue type:: bug`. On other nodes the tag is a tag. An option is matched as written: `tech-debt` by `#tech-debt`, and `Tech Debt` by `[#Tech Debt]` (L29), never by `#tech-debt`. On a reference field (M24), a tag also names a node of its types, the value then referring to that node: first by its label as written, then by its name (M23), and last by its ID. With `options:: +project` and `tags:: true`, `#ord-notes` on a task refers to `Ord-notes +project ^abc123`, `#ord` to `Ord #new +project`, before a node whose ID is `ord`, and `[#Ord Notes]` (L29) to `Ord Notes +project`. A tag is matched only against what is written, never against a slug: `#ord-notes` doesn't name `Ord Notes +project`. When fields of two of a node's types take one tag, the last type's field has it (M36). The text stays as written. - **M39.** A formula (L12) can be written wherever a field's value goes, and is then a **formula item**: on a field line, alone or among other items (`total:: =(a + b)`, `tags:: draft; =(project._tags)`), in an inline field (`[total:: =(a + b)]`), or as a child line of a field line that holds only the formula and has no child lines of its own, which is the same item as the formula written on the field line: ``` total:: =(a + b) ``` means what `total:: =(a + b)` does. On an ordinary node, a formula item stands for its result: one item, one item per element when the result is a list, and none when it is empty. A field with formula items is a **computed field**, written on the node, unlike a calculated field (M87): its value is its items in order, each formula item replaced by its result, so formulas and plain values can be mixed, and a field can have several formulas. A result with objects is the field the [JSON mapping](JSON_mapping.md) reads it as (J9, J10, J20), each object fields, never a node (J26), and each member a field: plain elements are items, one object is the field's anonymous node (C13), as `contact::` with `primary:: anna` under it reads as `{"primary": "anna"}` (M41), and several, or an array with `null` or a nested array, are index fields, `0::`, `1::` and so on, each with its members under it (J20), not a field line each as J10 writes records, since the result is one field's, and `{}` is `{}`; formulas read them back as the same array (M41). An editor shows each formula item's result after the formula, where it is written, the items joined by `; `. A result with objects it shows under the formula's line instead, as it shows calculated fields (M87): a row for each field, `key = items`, a field whose value is an object as `key::` with its fields on the rows under it, one level in, and first a row `= items` for the items that aren't objects, so `=({"a": 1, "b": {"c": 2}})` shows `a = 1`, then `b::` with `c = 2` under it. Each object of several shows on a row of its own, its first plain field, with its other fields on the rows under it. Where a result is text in one line, as in a name (M11), an object is its fields as `key:: items`, separated by `, `: `a:: 1, b.c:: 2`. A `=expr` value of a setting of a node of a system type (M12), other than a field definition node's `value` and `valid` and a search node's `footer` (M64), is the error `M39`; the formula isn't evaluated. - **M87.** **Calculated fields.** A field definition (M36, M55) whose `value` is a formula, `=expr` (L12), defines a **calculated field**. Every node the definition's value applies to (M37, M57) has the field, with the formula's result as its value, evaluated on the node (M41) as a formula item is (M39), so a list gives one item per element and nothing gives none. The field is never written on the nodes, and a file read as plain text doesn't hold it (M86). On a local field definition, the formula is written after the key on its line and must start there; one over several lines (C52) continues under it: ``` Expense +_type name:: expense fields:: line_a:: line_b:: total:: =(line_a + line_b) valid:: =($value >= 0) ``` An editor shows a calculated field first under the node line, before what is written under the node, as its key, ` = ` and its result, separated by `; ` when there are several: `by a boat +expense`, with `line_a:: 2000` and `line_b:: 50` under it, shows `total = 2050` above them. It is drawn apart from field lines, and can't be edited there; an evaluation error shows in its place (M44). Formulas, queries and mirrors read it as they read any field (M86). Its other settings apply to its result: `valid` checks it (M40), `options` (M46) says what it is meant to hold, `tags` (M47) lets a query match its value by a tag, though a tag on a node never sets it, and `icon` and `description` are as in M52. A diagnostic about a calculated field's result is on the node's line. A node that has a calculated field from several types has the last type's (M36). A nested field definition (M36) with a formula is calculated the same way, on the field's anonymous node (C13) but evaluated on the node (M41), and shown first under that field's line. A field line with nothing on it or under it, as `parts::`, counts as having an anonymous node with no lines, so its nested calculated fields are there too: with `parts::` and `double:: =(line_a * 2)` under it on the type, a node with `line_a:: 10` and an empty `parts::` has `parts.double`, 20, shown under its `parts::` line. A node can't write a field it calculates: a value for that key on the node, in any form, is the error `M87.1`, and is ignored. A child field line under a calculated field's definition whose key isn't a setting (M56) is the error `M87.2`, since a calculated field has no nested fields, and so is a formula alone on a child line of a local field definition, which isn't its value; both are left out. - **M40.** A `valid` setting holds `=expr`, a check. Each value written for the field on a node the definition applies to (M36), other than a formula, is checked on its own: the expression is evaluated on the node (M41), with `$value` bound to that value and `$values` to all the node's written values for the field, as a list. A calculated field's (M87) result is checked once, `$value` and `$values` both its value. A check whose result isn't true is the error `M40`, on the value, or on the node's line for a calculated field, and the value stays. A check that fails to evaluate is the error `M44.3`, on the definition. - **M41.** **Formula language.** A formula's expression is JSONata 2.x, written `=(…)` so that `$` is allowed (L12). The current node is `$`, the graph root `$root`, and a node is an object with its fields as members, system fields included: `_parent` is its owner (M13) and `_children` the nodes it owns (M16). A reference field's value is the node it refers to, and a field with field children (C13) is an object of them, or, when they are index fields, `0::`, `1::` and so on in order with unquoted keys (JSON mapping J20), an array of their values: with `r::` and `0:: a`, `1::` and `2:: b; c` under it, `r` is `["a", null, ["b", "c"]]`. A quoted key, `"0"::`, keeps an object. A field's value is its item when it has one and an array when it has several, and always an array when it is a list (C16): with `x:: a;` or `[x:: a;]`, `$type(x)` is `array`, and with `x:: ;`, `$count(x)` is 0. A formula in a field line under another field, at any depth, is evaluated on the node that owns the outermost field, not on the anonymous node it is written in: with `first:: =(sublevel.second & _tags)` and `sublevel::` with `second:: =(_label)` under it on the node `Test #tag`, `$`, `_label`, `_parent`, `_children`, `_id` and the other fields are the same in both formulas, and `second` is `Test #tag`. A node is true wherever a value is tested for truth, as in `a ?: b`, `a ? b : c`, `and`, `or`, a predicate `[…]`, `$boolean` and `$not`, whatever fields it has: `_parent ?: "none"` gives the owner even when it has no fields of its own. Nine system fields also have one-letter aliases: `L` is `_label`, `N` `_name`, `P` `_parent`, `C` `_children`, `S` `_state`, `G` `_tags`, `Y` `_types`, `I` `_id` and `R` `_result`. A node's own field with the same key as an alias comes before it. A formula's result can be a function, `function($x){ $x * 2 }`, alone or as a member of an object, and other formulas call it where they read the field: with `double:: =(function($x){ $x * 2 })` on `Lib`, `$node("Lib").double(21)` is 42. A function reads the nodes and variables where it is written, so in its body `$` and bare names are its node's, not the caller's: pass the caller's node in, as `$node("Lib").label($$)`, where `$$` is the node the formula runs on and `$`, inside the path, would be `Lib`. An editor shows a function as `ƒ` and its parameters, `ƒ($x)`. A function can't be written in a file: a one-time formula (M85) whose result holds one is an evaluation error (M44.3). **Workspace formulas.** A `formulas::` field line in the workspace file (Spec F5), at any depth, under a node or not, holds fields that every formula in the workspace reads as `$` names: with `formulas::` and `double:: =(function($x){ $x * 2 })` and `rate:: 0.25` under it, any formula can write `$double(21)` and `100 * $rate`. They are evaluated on the workspace, wherever they are written: `$` in them is `$root`, so `files:: =($count($.C))` counts the files. They can read each other, and their dependencies and cycles are those of fields (M44). A binding in a formula comes before them: in `($double := 3; $double)`, `$double` is 3. A key that can't be written after `$` (a letter or `_`, then letters, digits and `_`), or that is the name of a JSONata or Ord function, such as `sum` or `node`, is the error `M41.1` and binds nothing; a key that another `formulas::` field already gave, in file order, is the error `M41.2`, and the first counts. `formulas::` in any other file is an ordinary field. - **M43.** Formulas are pure, except `$today()`, `$now()`, `$date()` with a date name (M78) such as `"tomorrow"` and `$days()` with one argument, whose results follow the clock. One-time formulas (M85) may also use the generators (M93), whose results differ on each call; elsewhere they are an evaluation error (M44.3). - **M44.** Dependencies are per node and field, calculated fields (M87) included. Fields in a cycle are empty, with the error `M44.1` naming the whole path; fields that depend on a cycle are empty, with the error `M44.2`. An evaluation error leaves its formula item without a result, with the error `M44.3`; the field's other items stay. - **M42.** The function library adds `$node(text)`, `$nodes(under?)`, `$query(text, under?)`, `$ancestors(node?)`, `$today()`, `$now()`, `$date(text, days?)`, `$days(a, b?)`, `$format(x, picture)`, `$slug(text?)`, `$first(x)` and `$last(x)`, which M74 to M83 and M91 define, and, in one-time formulas only, the generators `$seq(n)`, `$uuid()`, `$id()` and `$sid()`, which M93 defines. Dates are ISO text. - **M74.** `$node(text)` gives the node that `text` names, as a link does: the node whose ID (M20) is `text`, ignoring letter case and spaces and tabs at either end, else the node whose label matches it (M23). Text that starts with `^` names a node by its ID only: `$node("^i42")`, and `Label^id` by its ID, as in a link (M22). Text that is one node's ID and another node's label gives the ID's node, with a warning. Text that names no node, or a label that matches several, gives nothing, with a warning. Unlike a reference field (M24), it matches nodes of any type. A number is read as its text, and a list gives the nodes its items name, leaving out those that name none; any other value gives nothing. Any text works, so `$node("journal-" & $today())` is today's journal node. - **M75.** `$nodes()` gives every node in the workspace, other than each file's root node (M13), field items (C13) and mirrors (M48): depth first, each node before the nodes it owns, in file order. Archived nodes (M63) are included. `$nodes(under)` gives only the nodes `under` owns, at any depth, in the same order; `under` is a node, or text naming one as `$node()` does, with its warnings, or a list of them, giving each node once. When it names no node, or the node owns none, the result is empty. The result is a list of nodes, filtered with JSONata on any field, system fields included: `$nodes()["task" in _types and _state != "done"]`. - **M76.** `$query(text, under?)` gives the nodes the query `text` matches, by the query rules (M61 to M63, M65), in file order: `$query("+task #project [ ]")`. With `under`, as in M75, only those `under` owns, or that a mirror it owns stands for (M65). A query that doesn't parse, or that holds a formula, is an evaluation error (M44.3); a formula's result is filtered instead: `$query("+task")[due < $today()]`. A formula that uses `$query()` depends on every node's types, tags, states and fields. - **M91.** `$ancestors(node?)` gives the node's ancestors, the nearest first: its owner (M13), its owner's owner, and so on, its file's root (C14) last, each once. Without `node` it is the formula's node (M41); `node` is a node, or text naming one as `$node()` does (M74). Mirrors (M48) are never ancestors, so the places a node is mirrored to don't count. A filter picks the nearest that matches: `$ancestors()["project" in _types][0]` is the nearest project, and `$ancestors()[client][0].client` the nearest ancestor's client. As a field's `value` (M37), a one-time formula over it lets a field start with a value from the node's ancestors: with `project:: ~($ancestors()["project" in _types][0])` and `options:: +project` on the type `task`, `[ ] Send mapping draft +task` under `Apollo +project` gets `project:: Apollo`. A formula that uses `$ancestors()` depends on the ownership of the nodes above its node. - **M77.** `$today()` gives today's date in local time, as a date (L23): `2026-10-22`. `$now()` gives the local date and time, as a datetime (L24) with seconds and without an offset: `2026-10-22T14:30:05`. Local time is the time zone of the tool that evaluates the formula. - **M78.** A **date name** is one of these, in any letter case: `today`, `tomorrow`, `yesterday` (or `yday`) and `now`; a weekday, `monday` to `sunday`, which is the next one, today included; and `this-`, `next-` or `last-` followed by a weekday, which is that day in this, the next or the last week, or by `week`, `month` or `year`, which is that period (M79). Weeks start on Monday (L25). `now` is a datetime, the periods are lists of dates, and the others are dates. - **M79.** `$date(text, days?)` reads `text` without spaces and tabs at either end. A date (L23) or a datetime (L24) gives itself. A week or a month (L25), or a year written as four digits, gives a **period**: the list of its dates, in order, so `due in $date("2026-W42")` works. A date name (M78) gives what it names. A number is read as its text, so `$date(2026)` is that year. Anything else, a week that doesn't exist included, gives nothing, with a warning. With `days`, a number, each date is shifted by that many whole days, the number truncated toward zero, and a datetime keeps its time and offset: `$date("2026-10-22T09:00", 7)` gives `2026-10-29T09:00`. A `days` that isn't a number is ignored. - **M80.** `$days(a, b)` gives the whole days from the date of `a` to the date of `b`, negative when `b` is earlier, ignoring the times of datetimes: `$days("2026-10-20", "2026-10-22")` is `2`. `$days(a)` counts from today to `a`. `a` and `b` are dates or datetimes; anything else, a date name or a period included, gives nothing. - **M81.** `$format(x, picture)` writes a number or a date with a JSONata picture. A number is written as JSONata's `$formatNumber` does: `$format(1234.5, "#,##0.00")` gives `1,234.50`. A date or a datetime is written as `$fromMillis` does: `$format("2026-10-22", "[D1] [MNn] [Y]")` gives `22 October 2026`. A date is read as its midnight, a datetime without an offset at its time as written, and one with an offset is written in UTC. Any other value, or a `picture` that isn't text, gives the value as text, and nothing gives nothing. - **M82.** `$slug(text)` gives the slug of the text (M45): `$slug("Åsa Öberg!")` gives `asa-oberg`. A number is read as its text, and a list gives the slug of each item; any other value gives nothing. A slug can be empty: `$slug("2026")` gives `""`. `$slug()`, with no argument, gives the slug of the formula's node's name (M23): on `Åsa Öberg! #team`, `asa-oberg`, and nothing on a node without a label. An argument that is nothing, as a field the node doesn't have, still gives nothing: `$slug(missing)` isn't `$slug()`. - **M45.** A **slug** is the text in lowercase, accents removed, each run of characters other than letters and digits turned into one `-`, with leading digits and `-` and trailing `-` removed. - **M83.** `$first(x)` and `$last(x)` give the first and the last item of a list, and nothing for an empty list. Any other value gives itself, so a field with one value or several reads the same way: `$first(owner)`. - **M85.** **One-time formulas.** A one-time formula, `~(…)` or `~expr` (L32), on an ordinary node, in a label or as a field's item, is evaluated as a `=` formula there would be (M39, M41), and a tool writes its result in its place, so the file holds the value, not the formula: in a field, the result written as the field the [JSON mapping](JSON_mapping.md) reads it as (J9, J10, M39), by the writer that writes every field (C16, C26), except that a string is written bare even when it reads as a number or a boolean, so `code:: ~$seq(1)` gives `code:: 1`: `due:: ~$today()` becomes `due:: 2026-11-06`, `~(["a", "b"])` gives `a; b`, `~(["a"])` gives `a;`, and text with a `;` or a line break is quoted, as `"x\ny"`; in a label, the result's text, a list's items joined by `; ` and a line break written as a space. A node in a field's result is written as a reference to it (M21): its name (M23), or `Label^id` when the name alone doesn't name it (M22), the tool giving it an ID when it has none. Objects in the result (M39) are written as their field's lines under the field's line, one level deeper, after its other lines: `x:: ~({"a": 1, "b": {"c": [2, 3]}})` becomes `x::` with `a:: 1` and `b::` under it, and `c:: 2; 3` under `b::`, and `x:: ~([{"a": 1}, {"a": 2}])` becomes `x::` with the index fields `0::` and `1::` under it, `a:: 1` under the first and `a:: 2` under the second (M39); the formula goes from the line with the `;` next to it. Objects can't be written in a label, an inline field or a formula alone on a child line, nor one object when the field already has field lines under it, since a field has one anonymous node (C13): the formula stays, with that error. A tool does this once the formula is no longer being edited, in a file it edits or shows. An editor that knows its cursor writes it once the cursor is neither in it nor right before or after it, as after a space, a line break or a tap elsewhere, and until then shows its result, as for a `=` formula (M39). When a character typed right after it turns it into another formula that fails, or into text, as `~$today()x`, the result it showed takes its place and the character stays after it. A tool without a cursor writes a formula that ends where the person is typing once a space or a line break follows it, and one elsewhere once edits pause. A result that is an error isn't written: the formula stays, and an editor shows the error after it, as for a `=` formula (M39). In a field, an empty result, nothing, text of only spaces and tabs, or a list of only such, is written as nothing: the formula goes, with its item, so `x:: ~(missing ?: "")` becomes `x::` and `n:: ~(missing); keep` becomes `n:: keep`. In a label, it isn't written: the formula stays, with that error. Until a tool replaces it, a one-time formula has no value: as a field's item, it adds no item. A `value` of `auto expr`, the form this replaces, isn't evaluated, with no problem: write `~(expr)`. - **M93.** **Generators.** A one-time formula (M85) can use four functions that make a new value each time: - `$seq(n)` gives the next number, written with at least `n` digits, leading zeros added: one more than the largest number at the end of a value of the field (of the ID, for `_id`) on the nodes of a type, ignoring formulas, and 1 when there is none. The type is the one whose definition of the field applies to the node (M36), else the node's last type, and with no types every node counts. One tool run gives each call the next number, so several nodes written at once get 7, 8, 9: with `_id:: ~("BE" & $seq(3))` on `bug`, and bugs up to `^BE006`, a new bug gets `^BE007`. `n` is truncated toward zero, and one that isn't a number above 0 means no padding. - `$uuid()` gives a random UUID, as `6f1c2a4e-9b0d-4c1e-8f3a-2d7b5e9c1a40`. - `$id()` gives six random characters, a lowercase letter, then lowercase letters and digits, as `k3x9pq`. - `$sid()` gives the slug of the node's name (M23, M45), `-` and three random lowercase letters and digits, as `send-proof-k3x`, or, for a name with no slug, what `$id()` gives. A tool that writes an ID from a type's formula (M37) tries again, a few times, while the result is no name (L3) or another node's ID, and then makes one up. ## 9. Queries Tests in Appendix A cover each rule of this section. - **M60.** A node with the type `search` (M53) is a **search node**. It is written only as an inline search, `? query` ([Ord specification](Ord_Specification.md) L28): its query is what follows the `?`, on one line, and its other settings, the view settings (M64), are its field lines. A filter too long for the line is better a calculated field on a type (M87), queried as `=(late)`. `search` written as a type any other way, as `+search`, `[_types:: search]` or a `_types::` line, gives the node no type `search` and makes no search, with no problem; a `query` field line under a search node is not read, with no problem either. On any other node, `query::` is an ordinary field. A search has no label of its own (L28): where a name is needed, such as its results document, it is named by its query. - **M61.** A query is terms, joined by spaces for and, `|` for or, and grouped by parentheses; `!` before a term or group negates it. A term is `+type`, `#tag`, a state trigger, a link, a mirror term `@` and a reference (M65), a field `[key:: value]`, or `[key::]` with no value, which is the formula `=($exists(key))`, a formula `=(…)`, or a word, which matches a node's text (M62). - **M62.** A node matches `+type` when it has the type, `#tag` when it has the tag or a tag nested under it, ignoring letter case (`#project` matches `#project/apollo`), or, when a field of one of its types with `tags:: true` (M47) would take the tag, when that field's value is what the tag would give it (with `tags:: true` and `options:: +project` on `project`, `#LU` matches a task with `project:: LU` as well as one written `#LU`), `[x]` and the other triggers when its state or its base is that state, a link when one of its fields refers to the node it resolves to, `[key:: value]` when one of its `key` values equals the text, ignoring letter case, or, when the text is a value form (L21) other than `text` (L35), is a value of the same form with the same value: numbers as numbers, so `[n:: 1.5]` matches `n:: 1.50`, and datetimes as the same time, so `[at:: 2026-10-15T14:30]` matches `at:: 2026-10-15 14:30` (a datetime with an offset matches one with the same moment, one without an offset only one without), a computed field's (M39) and a calculated field's (M87) values included, as the text their results are written as (a node by its ID or name), a formula when its result is true, and a word when its label contains it, ignoring letter case, or else its ID, one of its types, one of its tags, or one of its fields' keys or values as written does, system fields other than `_tags` left out: `be086` matches `Mentions be086`, `Event ^BE086` and a node with `ref:: BE086`. A word written with `*`, outside quotes, is a pattern that one of these texts must match whole, each `*` standing for any characters, none too, ignoring letter case: `jour*` matches a label, ID, type, tag, key or value that starts with `jour`, `*notes` one that ends with `notes`, and a label also matches when its name (M23) does. A word written `^word` matches a node's ID only, and `^journal*` the nodes whose IDs start with `journal`; `^` alone is a word. A quoted word is literal: `"jo*"` holds a `*`. An editor that lists a search's results without a `sort` setting lists the nodes whose labels hold its words (not its `^` words) first, then the others, each in file order. - **M63.** Nodes tagged `archived` match only queries that name `#archived`. - **M64.** A search node's view settings are `view`, `fields`, `sort`, `group` and `footer`. What they show, and how, is implementation; what they hold is specified here. A `view` holds how the results are shown, such as `list`, `table`, `board` or `calendar`. A `fields` setting holds the **columns**, one field line each under it, on its anonymous node (C13), in order: `key::` with no value is the field `key` of each result, a system field (M11) included, as `_label::` or `_state::`, and `key:: =expr` is a **template column** named `key`, the formula's result evaluated on each result (M41), shown and never written. A column's child lines are the implementation's own, and nothing in this spec reads them. Without `fields`, an editor chooses the columns, such as the label and the fields of the results' types. A `sort` holds conditions as items (C15), applied in turn, each a field key, then optionally `asc` or `desc` and then optionally `number` (or `num`), `text` or `date`; the defaults are `asc` and `text`. Text compares as people read it, ignoring letter case and with each run of digits as a number, so `30` comes before `120`, and `Item 9` before `Item 10`. A `group` holds a field key; the results are grouped by its value. A `footer` holds `=expr`, evaluated with the list of the results' nodes as `$`, and is shown with the results, and with each group's; nothing else reads it, and it is never written into a file (M86). - **M65.** A query matches a node in its own place, never a mirror (M48), so a node mirrored in three places is one result. The term `@` and a reference, written as in a mirror line (L30) but with no space after `@`, matches the node the reference resolves to. A query is scoped by `$query(text, under)` (M76) to the nodes `under` owns, at any depth, and a node is in the scope when it or one of its mirrors is: a mirror owned by `under`, or by a node in the scope, puts its source in, so `$query("@anna", "Team")` finds `Anna` when `Team` holds `@ Anna`. A query has no terms of its own for a scope. A search node (M60) never matches a query: it is a query, not a result. ## 10. Diagnostics Codes, severities and positions work as in the Spec (C35 to C37). Positions are in the file the diagnostic is about. - **M90.** **Paths are not checked for portability.** A path in a file, a path link (L14), a mirror's path (M48) or a `pinned files` value (M89), gets no diagnostic for being one that may not work on another machine: an absolute path (`/Users/anna/plan.ord`, `C:\notes`), one starting with `~/`, one with `\` between folders, one that leads outside the workspace, or one whose letter case differs from the file's name on a file system that ignores case. Whether a path names a file is decided where the workspace is read, as it is: a mirror's path that names no file there is still `M48.1`, and nothing else is given. An editor may offer to rewrite a path, but not as a problem. | Code | Severity | Given when | Position | |---|---|---|---| | `M10` | error | A node has a second `_label`, `_id`, `_state` or `_mirror` value | the second value | | `M11.1` | error | A node writes a `_name` value | the value | | `M11.2` | error | A node writes a `_file` value | the value | | `M14.1` | warning | A `_parent` cell names a node owned by indentation | the cell | | `M14.3` | warning | A CSV file has a `_children` cell | the cell | | `M15` | error | A node is in an ownership loop | the node | | `M17.1` | error | A type definition's `name` isn't a name, or a tag definition's isn't a tag | the value | | `M17.2` | error | A type or a tag is defined twice, or a system type in a file | the second `name` field | | `M17.3` | warning | A type definition has no `name` | the `+_type` trigger | | `M20.1` | error | Two nodes have one ID | each ID after the first, in file order (M5) | | `M20.3` | error | An ID isn't a name | the ID | | `M22.1` | error | A reference's ID matches no node | the reference | | `M22.2` | warning | A reference's label no longer matches the node its ID names | the reference | | `M22.3` | warning | A reference is one node's ID and another node's label | the reference | | `M23.1` | warning | A label matches no node | the reference | | `M23.2` | warning | A label matches several nodes | the reference | | `M26` | warning | A `_state` value is neither a built-in state nor a custom state of the node's types | the value | | `M27.1` | warning | A custom state isn't `name [m] > base` with a built-in base and a new name | the `state` setting | | `M28.1` | warning | A custom state uses a built-in marker | the `state` setting | | `M28.2` | warning | A marker belongs to a custom state already | the `state` setting | | `M39` | error | A formula on a setting of a node of a system type, other than a field definition node's `value` and `valid` and a search node's `footer` | the value | | `M40` | error | A `valid` formula isn't true | the value, or the node's line for a calculated field (M87) | | `M41.1` | error | A workspace formula's key can't be written after `$`, or names a JSONata or Ord function | the field | | `M41.2` | error | A workspace formula's key is given by another `formulas::` field already | the field | | `M44.1` | error | A computed field is in a cycle | the formula | | `M44.2` | error | A computed field depends on a cycle | the formula | | `M44.3` | error | A formula fails to evaluate | the formula | | `M46` | warning | A value is none of the field's `options` | the value, or the node's line for a calculated field (M87) | | `M48.1` | warning | A mirror's path names no file of the workspace | the mirror's `_mirror` value | | `M50.1` | warning | A mirror is under its own source | the mirror's `_mirror` value | | `M50.2` | warning | A line is under a mirror | the line | | `M55.1` | error | A field is defined by two field definition nodes | the second `key` field | | `M55.2` | error | A system field (M11) is defined again | the `key` value | | `M55.3` | warning | A field definition node has no `key` | the `+_field` trigger | | `M58.1` | error | A type gives a field definition node's key a value or child lines | the field line | | `M87.1` | error | A node writes a field that one of its types calculates | the value | | `M87.2` | error | A calculated field's definition has a nested field, or a local field definition has a formula alone on a child line | the line | | `M92` | error | A name or key that starts with `_` names no system field or system type | the type, tag or ID, the field's key, or the `name` or `key` value | --- # Appendix A: Graph dump and tests Tests work as in the [Test format](Test_format.md), part B, with one more option. - **M70.** With the `graph` option, the input is a workspace and the expected output is its graph dump. The input holds one or more files, each starting with a line `--- ` and the file's path, e.g. `--- tasks.ord`. A path ending in `.csv` or `.tsv` is a CSV file. Formulas see 2026-10-15T14:30 as the date and time now (M77), or 14:30 on the date of a test option `today:YYYY-MM-DD`. - **M71.** The graph dump lists each file, in the order of M5, as `file` and its path, and under it, indented two spaces per level, its nodes by ownership (M16), starting with the root's children. A node is `node` and its label as a string (D8), or `node` alone when it has none, then `@` and its line when it has one, as `@path:line` when it is in another file than the one listed, and for a node item (C13), `in` and the field's key, e.g. `node "Erik" @12 in "contacts"`. - **M72.** Under a node, before its children, come only the facts this spec decides, in this order, each when present: `id`, `type` (one line per type), `state`, `base` when it differs from the state, `ref` lines: `ref`, the key, `->`, and the target's file and line as `path:line`, e.g. `ref "client" -> a.ord:1`, and `calc` lines, one for each of its calculated (M87) and computed (M39) fields, sorted by key: `calc`, the key, and each item of its value as a string, as an editor shows it (M39), e.g. `calc "total" "2050"`; a field with no items, or whose formula fails, is its key alone. A nested calculated field's key is its path, as `parts.double`. A label's formulas (`_result`, M11) aren't listed. A search node (M60) has, after them, a `result` line for each of its results, in the order an editor lists them (M62, M64): `result`, its group as a string with a `group` setting, `->` and the node's file and line, e.g. `result "travel" -> a.ord:4`; and with a `footer`, `footer` and its value, then for each group, in the order of its first result, `footer`, the group's value, `in` and the group, e.g. `footer "150" in "travel"`. A query that doesn't parse has no `result` lines. - **M73.** Diagnostics follow, one per line, sorted by file, line, column and code: `!`, the code, and `path:line:column`. - **M94.** With the `change` option, the input is a workspace, as for `graph` (M70), and then the files a person's edit changed, each starting with a line `=== ` and its path, as the file is after the edit. The expected output is every file, in the order of the input, each starting with a line `--- ` and its path, after the edits tools make once the person's edits have settled, in this order: on each node line the edit gave a type, a checkbox (M19), the content template (M51) and the types' fields (M37); a change to types' field definitions, written on their nodes (M84); and one-time formulas written over and IDs given (M85, M93), pass after pass until a pass writes nothing. Formulas see the date and time as in M70. Generators whose results are random (M93) aren't tested. ```example graph M8 M18 M20 M21 M22 M23 --- a.ord Acme Corp +company ^acme Anna +person Call [[Anna]] about [[Acme Corp]] client:: acme . file "a.ord" node "Acme Corp" @1 id "acme" type "company" node "Anna" @2 type "person" node "Call [[Anna]] about [[Acme Corp]]" @3 ref "_link" -> a.ord:2 ref "_link" -> a.ord:1 ``` ```example graph M10 M26 M27 M29 M30 --- types.ord Bug +_type name:: bug state:: triage [t] > new | review [r] > in-progress | shipped > done | someday --- work.ord [r] Fix login +bug Ship it +bug _state:: shipped Later +bug _state:: someday [x] Twice +bug _state:: shipped [q] Unknown Odd _state:: shipped . file "types.ord" node "Bug" @1 type "_type" file "work.ord" node "Fix login" @1 type "bug" state "review" base "in-progress" node "Ship it" @2 type "bug" state "shipped" base "done" node "Later" @4 type "bug" state "someday" node "Twice" @6 type "bug" state "done" node "Unknown" @8 node "Odd" @9 state "shipped" ! M10 work.ord:7:11 ! L11 work.ord:8:1 ! M26 work.ord:10:11 ``` ```example graph M5 M17 M18 M53 --- Ord.workspace Types +task Task +_type name:: task --- a.ord Write +task +task Task +_type name:: task . file "Ord.workspace" node "Types" @1 node "" @2 type "task" node "Task" @3 type "_type" file "a.ord" node "Write" @1 type "task" node "" @2 type "task" node "Task" @3 type "_type" ! M17.2 a.ord:4:2 ``` Names that start with `_` are reserved (M92): only the system fields and system types use them. ```example graph M92 --- a.ord Draft +_task #_draft ^_x1 _due:: 2026-12-01 Bug +_type name:: _bug . file "a.ord" node "Draft #_draft" @1 id "_x1" type "_task" node "Bug" @3 type "_type" ! M92 a.ord:1:7 ! M92 a.ord:1:14 ! M92 a.ord:1:22 ! M92 a.ord:2:2 ! M92 a.ord:4:9 ``` ```example graph M13 M14 M15 M20 M21 M24 --- a.ord Invoice 42 ^i42 Anna +person ^anna Erik ^anna Now ^today Task +_type name:: task fields:: owner:: options:: +person Fix +task owner:: "Anna" contacts:: Erik --- lines.csv _id,_label,_parent l1,Workshop,i42 l2,Review,l3 l3,Loop,l2 . file "a.ord" node "Invoice 42" @1 id "i42" node "Workshop" @lines.csv:2 id "l1" ref "_parent" -> a.ord:1 node "Anna" @2 id "anna" type "person" node "Erik" @3 id "anna" node "Now" @4 id "today" node "Task" @5 type "_type" node "Fix" @10 type "task" ref "owner" -> a.ord:2 node "Erik" @13 in "contacts" file "lines.csv" node "Review" @3 id "l2" ref "_parent" -> lines.csv:4 node "Loop" @4 id "l3" ref "_parent" -> lines.csv:3 ! M20.1 a.ord:3:6 ! M15 lines.csv:3:1 ! M15 lines.csv:4:1 ``` ```example graph M23 --- a.ord Buy milk #urgent Anna #friend See [[Buy milk]], [[buy milk #urgent]] and [[anna]] . file "a.ord" node "Buy milk #urgent" @1 node "Anna #friend" @2 node "See [[Buy milk]], [[buy milk #urgent]] and [[anna]]" @3 ref "_link" -> a.ord:1 ref "_link" -> a.ord:1 ref "_link" -> a.ord:2 ``` ```example graph M23 --- a.ord Ship **v2** now Plan _the_ ==launch== See [[Ship v2 now]], [[ship *v2* now]] and [[Plan the launch]] . file "a.ord" node "Ship **v2** now" @1 node "Plan _the_ ==launch==" @2 node "See [[Ship v2 now]], [[ship *v2* now]] and [[Plan the launch]]" @3 ref "_link" -> a.ord:1 ref "_link" -> a.ord:1 ref "_link" -> a.ord:2 ``` ```example graph M21 M48 M49 --- a.ord Monday ^journal Standup @ Send mapping draft^t9x1 Kickoff attendees:: @ Anna Smith with:: @Anna Smith; @Nobody Anna Smith +person Apollo +project [-] Send mapping draft +task ^t9x1 Ask Erik @ ^gone . file "a.ord" node "Monday" @1 id "journal" node "Standup" @2 node "" @3 ref "_mirror" -> a.ord:10 node "Kickoff" @4 ref "attendees" -> a.ord:8 ref "with" -> a.ord:8 node "" @6 in "attendees" ref "_mirror" -> a.ord:8 node "Anna Smith" @8 type "person" node "Apollo" @9 type "project" node "Send mapping draft" @10 id "t9x1" type "task" state "in-progress" node "Ask Erik" @11 node "" @12 ! M23.1 a.ord:7:22 ! M22.1 a.ord:12:2 ``` ```example graph M48 M50 --- a.ord Apollo +project Tasks @ Apollo @ Tasks Stray note . file "a.ord" node "Apollo" @1 type "project" node "Tasks" @2 node "" @3 ref "_mirror" -> a.ord:1 node "" @4 ref "_mirror" -> a.ord:2 node "Stray note" @5 ! M50.1 a.ord:3:3 ! M50.2 a.ord:5:3 ``` A search is written `? query` (M60); `+search` and a `query::` line under a search are errors. ```example graph M60 --- a.ord Open +search query:: +task ? +task query:: #urgent sort:: due . file "a.ord" node "Open" @1 node "" @3 type "search" ``` A mirror of a file (M48): its source is the file's root, its path resolved from the mirror's folder. ```example graph M48 --- a.ord Today @ notes/plan.ord @ missing.ord --- notes/plan.ord Top . file "a.ord" node "Today" @1 node "" @2 ref "_mirror" -> notes/plan.ord node "" @3 file "notes/plan.ord" node "Top" @1 ! M48.1 a.ord:3:2 ``` ```example graph M36 M46 M55 M57 M87 --- a.ord Task +_type name:: task fields:: priority:: options:: low; high score:: =(1) Bug +_type name:: bug fields:: priority:: options:: p1; p2 score:: =(2) Note +_field key:: note options:: ok A +task +bug priority:: p1 note:: ok B +bug +task priority:: p1 note:: bad . file "a.ord" node "Task" @1 type "_type" node "Bug" @7 type "_type" node "Note" @13 type "_field" node "A" @16 type "task" type "bug" calc "score" "2" node "B" @19 type "bug" type "task" calc "score" "1" ! M46 a.ord:20:13 ! M46 a.ord:21:9 ``` ```example graph M40 M87 --- a.ord Expense +_type name:: expense fields:: line_a:: line_b:: total:: =(line_a + line_b) valid:: =($value >= 0) parts:: double:: =(line_a * 2) By boat +expense line_a:: 2000 line_b:: 50 parts:: Refund +expense line_a:: -100 line_b:: 20 total:: 5 . file "a.ord" node "Expense" @1 type "_type" node "By boat" @10 type "expense" calc "parts.double" "4000" calc "total" "2050" node "Refund" @14 type "expense" calc "total" "-80" ! M40 a.ord:14:1 ! M87.1 a.ord:17:10 ``` ```example graph M39 M44 --- a.ord Sums a:: 2 b:: =(a * 3); 7; =([1, 2]) c:: =(d) d:: =(c) e:: =(c + 1) f:: =($undefinedFn(1)) . file "a.ord" node "Sums" @1 calc "b" "6" "7" "1" "2" calc "c" calc "d" calc "e" calc "f" ! M44.1 a.ord:4:6 ! M44.1 a.ord:5:6 ! M44.2 a.ord:6:6 ! M44.3 a.ord:7:6 ``` ```example graph M47 M24 --- a.ord Issue +_type name:: issue fields:: kind:: options:: bug; feature tags:: true project:: options:: +project tags:: true label:: =(_tags) Ord-notes +project ^on1 Ord Notes +project Crash +issue #bug #ord-notes #other Wish +issue [#Ord Notes] Elsewhere #bug label:: =(_tags) . file "a.ord" node "Issue" @1 type "_type" node "Ord-notes" @11 id "on1" type "project" node "Ord Notes" @12 type "project" node "Crash #bug #ord-notes #other" @13 type "issue" ref "project" -> a.ord:11 calc "label" "other" node "Wish" @14 type "issue" ref "project" -> a.ord:12 calc "label" node "Elsewhere #bug" @15 calc "label" "bug" ``` ```example graph M40 --- a.ord Item +_type name:: item fields:: qty:: valid:: =($value > 0 and $count($values) <= 2) Good +item qty:: 3 Bad +item qty:: 0; 2; 5 . file "a.ord" node "Item" @1 type "_type" node "Good" @6 type "item" node "Bad" @8 type "item" ! M40 a.ord:9:8 ! M40 a.ord:9:11 ! M40 a.ord:9:14 ``` ```example graph M41 M74 M82 M83 --- a.ord Åsa Öberg! #team ^asa s:: =($slug()) t:: =($slug("Hej då")) m:: =($slug(missing)) n:: =($node("^asa")._label) f:: =($first([3, 4])) l:: =($last(9)) k:: =(N) . file "a.ord" node "Åsa Öberg! #team" @1 id "asa" calc "f" "3" calc "k" "Åsa Öberg!" calc "l" "9" calc "m" calc "n" "Åsa Öberg! #team" calc "s" "asa-oberg" calc "t" "hej-da" ``` ```example graph M24 M40 M42 M43 M44 M45 M46 M56 M58 M75 M76 M82 M91 --- a.ord Person +_type name:: person Task +_type name:: task fields:: Owner +_field key:: owner options:: +person description:: Who does it. due:: description:: When it is due. size:: small valid:: =($value in ["small", "large"]) priority:: Priority +_field key:: priority options:: low; high Anna +person Apollo Draft +task owner:: Anna size:: huge priority:: urgent up:: =($ancestors()[0]._label) all:: =($count($nodes("Apollo"))) tasks:: =($count($query("+task"))) slug:: =($slug("Åsa Öberg!")) g:: =($uuid()) . file "a.ord" node "Person" @1 type "_type" node "Task" @3 type "_type" node "Owner" @6 in "fields" type "_field" node "Priority" @15 type "_field" node "Anna" @18 type "person" node "Apollo" @19 node "Draft" @20 type "task" ref "owner" -> a.ord:18 calc "all" "1" calc "g" calc "slug" "asa-oberg" calc "tasks" "1" calc "up" "Apollo" ! M40 a.ord:22:10 ! M46 a.ord:23:14 ! M44.3 a.ord:28:7 ``` ```example graph M79 M80 M81 M83 --- a.ord Dates num:: =($format(1234.5, "#,##0.00")) day:: =($format("2026-10-22", "[D1] [MNn] [Y]")) week:: =($count($date("2026-W43"))) month:: =($first($date("2026-02")) & " " & $last($date("2026-02"))) shift:: =($date("2026-10-22T09:00", 7)) between:: =($days("2026-10-20", "2026-10-22")) back:: =($days("2026-10-22T23:00", "2026-10-20T01:00")) . file "a.ord" node "Dates" @1 calc "back" "-2" calc "between" "2" calc "day" "22 October 2026" calc "month" "2026-02-01 2026-02-28" calc "num" "1,234.50" calc "shift" "2026-10-29T09:00" calc "week" "7" ``` ```example graph M77 M78 M79 M80 --- a.ord Clock today:: =($today()) now:: =($now()) tomorrow:: =($date("tomorrow")) yday:: =($date("YDAY")) friday:: =($date("friday")) thursday:: =($date("thursday")) next:: =($date("next-friday")) last:: =($date("last-monday")) week:: =($first($date("this-week")) & " " & $last($date("this-week"))) left:: =($days("2026-10-20")) name:: =($days("tomorrow")) . file "a.ord" node "Clock" @1 calc "friday" "2026-10-16" calc "last" "2026-10-05" calc "left" "5" calc "name" calc "next" "2026-10-23" calc "now" "2026-10-15T14:30:00" calc "thursday" "2026-10-15" calc "today" "2026-10-15" calc "tomorrow" "2026-10-16" calc "week" "2026-10-12 2026-10-18" calc "yday" "2026-10-14" ``` ```example change M19 M36 M37 M47 M51 --- t.ord Todo +_type name:: todo checkbox:: true fields:: client:: options:: ACME; Initech tags:: true due:: vat:: =(1 + 1) nodes:: Notes Invoice +_type name:: invoice fields:: due:: 30 days amount:: --- a.ord Call Anna Pay amount:: 100 === a.ord Call Anna +todo #ACME Pay +todo +invoice amount:: 100 . --- t.ord Todo +_type name:: todo checkbox:: true fields:: client:: options:: ACME; Initech tags:: true due:: vat:: =(1 + 1) nodes:: Notes Invoice +_type name:: invoice fields:: due:: 30 days amount:: --- a.ord [ ] Call Anna +todo #ACME due:: Notes [ ] Pay +todo +invoice amount:: 100 client:: due:: 30 days Notes ``` ```example change M84 M87 --- t.ord Invoice +_type name:: invoice fields:: vat:: 0.25 status:: open total:: 0 Local +_type name:: local fields:: vat:: 0.25 --- a.ord March +invoice vat:: 0.25 status:: open total:: 0 April +invoice vat:: 0.06 status:: open total:: 5 May +invoice +local vat:: 0.25 status:: open total:: 0 === t.ord Invoice +_type name:: invoice fields:: vat:: 0.12 state:: open total:: =(1 + 1) paid:: Local +_type name:: local fields:: vat:: 0.25 . --- t.ord Invoice +_type name:: invoice fields:: vat:: 0.12 state:: open total:: =(1 + 1) paid:: Local +_type name:: local fields:: vat:: 0.25 --- a.ord March +invoice vat:: 0.12 state:: open paid:: April +invoice vat:: 0.06 state:: open total:: 5 paid:: May +invoice +local vat:: 0.25 state:: open paid:: ``` ```example change M39 M85 M93 --- t.ord Bug +_type name:: bug fields:: _id:: ~("BE" & $seq(3)) code:: ~("C-" & $seq(2)) --- a.ord Old +bug ^BE006 code:: C-09 === a.ord Old +bug ^BE006 code:: C-09 New +bug Newer +bug Plan due:: ~$date("tomorrow") x:: ~([{"a": 1}, {"a": 2}]) n:: ~(1 + 1); ~("6"); keep bad:: ~$uuid( none:: ~(missing ?: "") Ship ~$today() . --- t.ord Bug +_type name:: bug fields:: _id:: ~("BE" & $seq(3)) code:: ~("C-" & $seq(2)) --- a.ord Old +bug ^BE006 code:: C-09 New +bug ^BE007 code:: C-10 Newer +bug ^BE008 code:: C-11 Plan due:: 2026-10-16 x:: 0:: a:: 1 1:: a:: 2 n:: 2; 6; keep bad:: ~$uuid( none:: Ship 2026-10-15 ``` ```example graph M60 M61 M62 M63 --- a.ord Task +_type name:: task fields:: project:: options:: +project tags:: true LU +project [x] Write journal notes +task #area/home due:: 2026-10-20 n:: 1.50 [ ] Mentions be086 +task #LU Event ^BE086 Old journal +task #archived Journal day ^journal-2026-10-15 ref:: journal ? +task ? journal ? #area ? #LU ? [n:: 1.5] | [due::] ? ![x] +task ? ^journal* ? jour* ? #archived journal Bad +search query:: +task . file "a.ord" node "Task" @1 type "_type" node "LU" @7 type "project" node "Write journal notes #area/home" @8 type "task" state "done" node "Mentions be086 #LU" @11 type "task" state "new" ref "project" -> a.ord:7 node "Event" @12 id "BE086" node "Old journal #archived" @13 type "task" node "Journal day" @14 id "journal-2026-10-15" node "" @16 type "search" result -> a.ord:8 result -> a.ord:11 node "" @17 type "search" result -> a.ord:8 result -> a.ord:14 node "" @18 type "search" result -> a.ord:8 node "" @19 type "search" result -> a.ord:11 node "" @20 type "search" result -> a.ord:8 node "" @21 type "search" result -> a.ord:11 node "" @22 type "search" result -> a.ord:14 node "" @23 type "search" result -> a.ord:14 node "" @24 type "search" result -> a.ord:13 node "Bad" @25 ``` ```example graph M64 --- a.ord Taxi +expense amount:: 30 kind:: travel Hotel +expense amount:: 120 kind:: travel Lunch +expense amount:: 15 kind:: food ? +expense sort:: amount desc number group:: kind footer:: =($sum(amount)) ? +expense sort:: kind; amount . file "a.ord" node "Taxi" @1 type "expense" node "Hotel" @4 type "expense" node "Lunch" @7 type "expense" node "" @10 type "search" result "travel" -> a.ord:4 result "travel" -> a.ord:1 result "food" -> a.ord:7 footer "165" footer "150" in "travel" footer "15" in "food" node "" @14 type "search" result -> a.ord:7 result -> a.ord:1 result -> a.ord:4 ``` ```example graph M65 M76 --- a.ord Anna ^anna Team @ Anna^anna in team:: =($query("@anna", "Team")._label) Elsewhere in elsewhere:: =($count($query("@anna", "Elsewhere"))) ? @anna . file "a.ord" node "Anna" @1 id "anna" node "Team" @2 calc "in team" "Anna" node "" @3 ref "_mirror" -> a.ord:1 node "Elsewhere" @5 calc "in elsewhere" "0" node "" @7 type "search" result -> a.ord:1 ```