Open App Definition (OAD) 0.2: Validation#
Status: working draft.
The key words MUST, MUST NOT, SHOULD, SHOULD NOT and MAY are to be read as in RFC 2119.
This chapter lists the semantic checks that a definition, a catalog and a design system pass in addition to their JSON Schemas. Each check has a stable diagnostic code, a severity and a one-line statement. A conforming definition validates against the 0.2 definition schema and produces no error from the checks below; the same holds for catalogs and design systems with their own schemas and checks.
1. Diagnostics#
A validator reports every problem it finds as a diagnostic:
| Field | Meaning |
|---|---|
code |
A stable code from the tables below, written <area>.<problem>. |
severity |
error or warning. An error makes the document non-conforming. A warning marks something legal that probably does not do what the author meant. |
pointer |
JSON Pointer (RFC 6901) to the offending value: the key, string or object that breaks the rule. A missing member is reported at the object that lacks it. |
message |
Human-readable explanation. Informative only. |
- A validator MUST report the code and severity given here, and the pointer given in the conformance fixtures. Messages MAY differ.
- A validator MUST collect all diagnostics rather than stop at the first.
- A validator MUST NOT fail on malformed input. A document that is not JSON data, or that is nested more than 256 levels deep, is reported as
document.invalid. - A document whose version marker is not
0.2is reported asdocument.versionand not checked further. - Checks run after schema validation. A validator MAY still run them on a document that fails the schema, and SHOULD then expect some overlap.
- Rules marked schema in the tables are also enforced by the JSON Schema, so no schema-valid document can break them. They are listed so that a validator running the checks on a schema-invalid document reports them consistently.
2. Terms#
- Resolve. Catalogs and included definitions are located by
idand semver range; the highest version that satisfies the range is used. A definition or design system is looked up first among the carried copies of the file the referring document came in (core.md, section 4), and a carried copy that fits is used whatever else is found. How a host finds them otherwise is outside this chapter. A reference into something that did not resolve is not checked further and produces no additional diagnostic; the static type of anything read from it isany. - Literal. A dynamic value with no expression in it. Its value is the JSON value with each leading
==replaced by=. Checks on values apply only to literals. - Literal input object. The
withof acall,run,code,navigateor statesource, theconfigof a capability, thewithof a part, when it is a JSON object (its members may still be expressions), and the input argument of acancall when it is a map literal. An absentwith, and acancall without an input argument, is an empty literal input object. - Used. An operation is used by every
callstep and every statesourcethat names it. A capability event is used by every rule trigger and refresh occasion that names it. A contract is used by every capability and node that names it, and a control contract named in thedegradeToof a used control is used too, and so on transitively. - Covered. An operation or capability event of capability
ais covered when some grant request withcapability: alists its scope inscopesand either has nooperationsor names it inoperations. A scope is covered when some grant request withcapability: alists it inscopesand has nooperations. - Static type. The type inferred for an expression, or given by a declaration, as defined in
expressions.md, section "Static types", with the types of roots and local names given in section 7.1. A static type is known when it is neitheranynornull.
3. Expression scope#
Each expression sees only the root names below, and the local names in scope at its position. The base roots are env, state, sources, capabilities, flows, parts, grants and user.
| Position | Roots |
|---|---|
State initial, capability config |
env |
Grant where, part grant where |
input, env |
derive, state source.with and source.when, rule when.becomes, part with, voice greeting |
the base roots |
Action allow, require (that and message), confirm.message |
the base roots and input |
Action done.message |
the base roots, input and output |
| Action steps | the base roots and input; plus error in onError steps and in orElse |
Rule if and do |
the base roots and event; plus error in onError steps and in orElse |
Flow transitions (if, allow, do), enter, exit |
the base roots and event; plus item and index in a collection flow, and error in onError steps and in orElse |
View state initial |
env, state, user and view |
Navigation section label, when, with, count and each; navigation group group and when |
the base roots |
View title, node when, props, each and bind |
the base roots and view |
| Visual event handlers | the view roots and event; plus error in onError steps and in orElse |
Voice intent reply |
the base roots, input and output |
Voice announce values |
the base roots and event |
where of remove and patch, and with of a patch that has where |
the enclosing roots and item, index, which hide any outer item and index |
Steps inside an each step, nodes inside a node with each (with their props, bindings and handlers), and the label, when, with, count and each.key of a navigation section with each |
the enclosing roots; plus item when as is not given, and index when indexAs is not given |
In a view state initial, view holds only the view's inputs. In a voice reply, state is the state after the action has committed; for an intent without an action, input is {} and output is null. In an action's done.message, state is the state as the action's steps left it, and output is the value the action produced. Which principal user is at each position, including derive, becomes, source.with, source.when and a part's with, is given in core.md, section "Who acts". A path's selectors (expressions.md, section "Paths") see the roots and local names of the step or node that holds the path, but not the item and index that a remove or patch binds for its where and with.
Local names. These bind a local name:
ason acall,runorcodestep, and aletstep: visible to the steps after the binding step in the same list, including steps nested inside them. A step's ownasis not visible in its ownwith,onErrorororElse. A local name bound inside a nested list (such as thethenof anif) is visible only in that list.asandindexAson aneachstep: visible in itsdosteps. On a node'seach: visible in the node itself (itswhen,each.key,props,bindand handlers) and in every node inside it, with their handlers. On a navigation section'seach: visible in the section'slabel,when,with,countandeach.key.- Variables a contract declares in a slot's
scope: visible inside that slot's template.
A later binding of a name hides an earlier one. Variables bound by list macros and let calls are local to the macro body.
Functions limited by position.
| Function | Allowed in |
|---|---|
random(), uuid() |
Step expressions: expressions inside action steps, rule do, transition do, enter, exit and visual event handlers, including a call step's once, the orElse of a call, run or code step, and a let step's to, but not path selectors. |
can(), canSend() |
Every position where user is a root, except derive, an action's allow, the that of its require entries, and a transition's if and allow. |
| Every other function | Everywhere. |
The guards that can and canSend evaluate are excluded so that a question can never ask itself.
4. Documents and names#
| Code | Severity | Rule |
|---|---|---|
document.invalid |
error | A document MUST be JSON data (plain objects, arrays, strings, finite numbers, booleans and null) nested at most 256 levels deep. |
document.version |
error | A document's version marker (oad, oadCatalog or oadDesign) MUST be 0.2. The message SHOULD say which version the validator reads. |
schema.invalid |
error | A document MUST validate against the OAD 0.2 JSON Schema for its kind. |
name.reserved |
error | No name MAY be true, false, null or in, no scope segment MAY be one of them, and no view MAY be named back. schema |
name.collision |
error | Capability aliases and part names MUST be distinct. A view's input fields and state entries MUST have distinct names. The as and indexAs of one each MUST differ. |
name.shadowsRoot |
error | A local name bound by as, indexAs or a let step MUST NOT be an expression root name. schema |
view.duplicateNodeId |
error | Node ids MUST be unique within a view, including nodes in slots and fallbacks. |
5. Uses and parts#
| Code | Severity | Rule |
|---|---|---|
uses.catalogNotFound |
error | Every entry of uses.catalogs, in a definition or a catalog, MUST resolve to a catalog with that id and a version in the range. A host can still load a definition whose catalog it lacks (core.md, section "Resolution and graceful degradation"); a validator needs the catalog to check it. |
uses.catalogCycle |
error | The graph of catalogs using catalogs through uses.catalogs MUST be acyclic. |
uses. |
error | Every entry of uses.definitions MUST resolve to a definition with that id and a version in the range. |
uses.designNotFound |
warning | uses.design SHOULD resolve to a design system; otherwise the host default applies. |
uses.digestMismatch |
error | A definition reference with digest MUST resolve to a document whose digest is exactly that value. |
part.cycle |
error | The include graph of definitions MUST be acyclic. |
part.tooDeep |
error | Included definitions MUST NOT nest more than 8 levels below the root definition. |
part.invalid |
error | Every included definition MUST itself be a conforming definition. |
part. |
error | A part's definition MUST be an alias in uses.definitions. |
part.unknown |
error | Every reference to a part (part nodes, run and can of part.action, parts.<name> in expressions, part.name in agent surface lists) MUST name a declared part. |
part.notExported |
error | A parent MUST use only what a part exports: with keys are exported inputs, parts. names exported state, run and can name exported actions, triggers name exported events, part nodes name exported views, and agent tools, resources and events lists name exported actions, state entries and events. |
part. |
error | Each key of a part's capabilities MUST be a capability alias of the part, and each value a capability alias of the parent. |
part. |
error | Mapped capabilities MUST reference the same contract name in catalogs with the same id and major version. |
part.grantUnknown |
error | Each key of a part's grants MUST name a grant request of the part. |
part.grantWidens |
error | A part grant adjustment MUST only narrow: scopes a subset of those requested, operations a subset of those the part's request names (or, when it names none, of the operations and events under its scopes), rate no higher, duration no longer, and scopes, operations or where only on capability requests. |
included.kind |
error | Every entry of included MUST be a definition or a design system of this version of the format (oad or oadDesign is 0.2) with a string id and a semantic version. A catalog is never carried. Reported at the entry, or at included when it is not an array. schema |
included.duplicate |
error | No two entries of included MAY be of one kind with the same id and version. Reported at the later entry. |
included.nested |
error | A carried definition MUST NOT have an included of its own. Reported at its included. schema |
included.reserved |
error | An entry of included MUST NOT have an id that begins with org.: such an id names a document of the format itself, which every host provides and no file carries (core.md, section 4). Such an entry is not looked up and not checked further. Reported at its id. schema |
included.unused |
warning | Every entry of included SHOULD be what some reference resolves to: a reference of the definition, or of a carried copy that a reference of the definition reaches. A copy nothing reaches is not checked further. Reported at the entry. |
The entries of included are the carried copies (core.md, section 4). A carried definition that a part resolves to is checked like any included definition (part.invalid), with its own references looked up among the copies of the file that carries it; the definition's other rules do not read the copies. A definition found elsewhere is checked as a file of its own, with its own included.
6. Types and values#
| Code | Severity | Rule |
|---|---|---|
type.unresolved |
error | Every type reference MUST resolve: a primitive, a name in types, or alias:TypeName with alias a key of the document's uses.catalogs and TypeName a type of that catalog; every $ref likewise. |
type.invalid |
error | A type schema's format MUST be date, date-time, duration or uri; its pattern MUST be a pattern in the dialect of expressions.md, section "Patterns"; minItems and maxItems MUST be non-negative integers with minItems not greater than maxItems; every value in a catalog type's known MUST be a value of that type (contracts.md section 1). |
type.cycle |
error | A named type MUST NOT consist only of $refs that lead back to itself. |
value.typeMismatch |
error | Literal state initial values, literal view state initial values, field defaults, literal capability config members, literal input members, literal control props, a literal once, and literal set to, append value, patch with and return values MUST conform to their declared types. A once is declared as a string of 1 to 200 code points. A written value's declared type is the one section 7.1 gives its place; a literal patch with is compared member by member, as section 7.1 says. |
value.notKnown |
warning | A literal value of a control prop whose type lists known values (contracts.md, section 1) SHOULD be one of them, and so SHOULD a literal meta.icon and a main section's icon in a definition that uses the core catalog, which take a name of its IconName (core.md, sections 3.1 and 12.2). Another value is valid, but a host need not know it, and a host that does not know an icon name shows no symbol. A value given by an expression is not checked, nor one the type does not accept (value.typeMismatch). The message names the three known values nearest to it by spelling. |
A value conforms to date when it is a calendar date YYYY-MM-DD, to datetime when it is YYYY-MM-DDTHH:MM:SS with optional fraction and Z or an offset, and to duration when it is an ISO 8601 duration as defined in expressions.md, section "Date, datetime and duration formats". A list conforms to minItems, maxItems and uniqueItems as in JSON Schema, with elements compared as in expressions.md, section "Equality".
7. Expressions and references#
| Code | Severity | Rule |
|---|---|---|
expression.syntax |
error | Every expression, every expression inside a dynamic value, and every path MUST parse. This includes the rules on let, can, canSend, t and literal matches patterns, and the rule that selectors appear only in the paths that allow them (expressions.md, sections "Grammar" and "Paths"). |
expression. |
error | Every free identifier of an expression MUST be a root present at its position (section 3) or a local name in scope there. |
expression. |
error | A function limited by position (section 3) MUST be called only where it is allowed: random() and uuid() in step expressions, can() and canSend() where section 3 allows them. |
expression. |
warning | Every function an expression calls SHOULD exist; a call to an unknown function always fails when evaluated. |
expression. |
error | A member access, or an index with a string literal, MUST NOT name a member that the closed map type of its target does not name (expressions.md, section "What is reported"). Under a root this covers every unknown name for which this table names no more specific code, such as grants.<name>, env.<name>, user.<name>, error.<name>, a typed event.<name>, and a member below a known entry. |
expression. |
error | An operator, function or list macro MUST NOT be applied to operands whose known types it cannot accept (expressions.md, section "What is reported"), and a computed value MUST NOT have a static type incompatible with the type of the place it goes (section 7.1). |
reference. |
error | state.<name> in an expression, the path of a changes trigger and the path of a refresh step MUST name a declared state entry. |
reference.notSourced |
error | sources.<name> MUST name a sourced state entry. |
reference. |
error | flows.<name> MUST name a singleton flow. |
reference. |
error | capabilities.<alias> MUST name a declared capability. |
reference. |
error | view.<name> MUST name an input field or a state entry of the view the expression belongs to; in a view state initial, an input field. |
reference. |
error | input.<name> MUST name a field of the input in scope: the action's input field map (in an action, its guards, steps and done.message, and a voice reply), or, in a grant where, a field of an operation input or event payload the request covers. |
The reference.* rules apply to a member access and to an index with a string literal (state['goal']), and each replaces expression.unknownMember for the name it covers.
7.1 Static types in a definition#
A validator infers the static type of every expression, dynamic value and path in a definition by expressions.md, section "Static types", and reports the operations that chapter's section "What is reported" names, and the incompatible values the rules below find. An expression that does not parse is not typed.
Roots. At each position, the roots have these static types. Every map type in this table is closed.
| Root | Static type |
|---|---|
state |
A member for each state entry, typed by its type. |
sources |
A member for each sourced entry: { status: string, error: { code: string, message: string }, updatedAt: string, partial: boolean }. |
capabilities |
A member for each capability alias: { available: boolean }. |
flows |
A member for each singleton flow: { state: string }. |
parts |
A member for each part: { state: S }, with S a member for each state entry the part exports, typed by its type in the part. |
grants |
A member for each grant request of this definition: { held: boolean, declined: boolean }. |
user |
{ id: string, kind: string, name: string, roles: list<string>, onBehalfOf: U, person: { id: string, name: string } }, with U this same type. |
env |
{ now, today, timezone, locale, currency, surface, invocation, direction: string, language: string?, online: boolean, host: { name: string, version: string } }. language is the shown language, null for a definition without localization (core.md section 12.7). |
input |
In an action's guards, steps and done.message, and a voice reply, the action's input field map. In a grant where, the union (expressions.md, section "Union") of the input field maps of the operations, and the payload field maps of the events, the request covers. In a part grant where, the same for the part's request. |
output |
The action's output type. When it declares none: null if no step of the action is a return, at any depth, and unknown (any) otherwise, since such a return is not checked. |
view |
A member for each input field and state entry of the view, typed by its type. |
item, index |
The element type of the list concerned (the target of remove or patch, a collection flow's collection, or the list an each iterates), and number. |
error |
{ code: string, message: string }. |
event |
As in the next table. |
Where event is in scope |
Static type of event |
|---|---|
A rule with a changes trigger |
{ previous: T, current: T }, with T the type at the trigger's path. |
A rule triggered by a capability event alias.event |
The event's payload field map. |
A rule triggered by action:<name> |
{ input: I, output: O }, with I the action's input field map and O what the root output is for that action (the first table). |
A rule triggered by flow:<name>, or a voice announce of flow:<name> |
{ from: string, to: string, event: string, key: any }. |
| A visual event handler | The control event's payload field map. |
Anywhere else (an emitted app event, a part's event, becomes, every and lifecycle triggers, flow transitions, enter and exit) |
any |
Local names.
| Local name | Static type |
|---|---|
as on call |
The operation's output type, or null when it declares none. |
as on run |
The action's output type (for part.action, as declared in the part). When it declares none: null if no step of the action is a return, at any depth, and unknown (any) otherwise. |
as on code |
The module's output type, or unknown (any) when it declares none: a module's result is checked only against a declared type. |
as on a step that has orElse |
The union of the type above and the type of orElse. |
as on an each step or a node's each |
The element type of the list it iterates. |
indexAs |
number |
A let step |
The type of its to. |
| A slot scope variable | The type the contract declares for it. |
Path types. A path is typed from its root: a name is a member access and a selector [f=e] gives the element type of the list before it. A selector applied to a type that is known and not a list is write.notList; a selector field that the element's closed map type does not name is expression.unknownMember. The selector expression is typed and checked as any expression, and is not compared with the field.
Where values go. A computed value at each place below MUST have a static type compatible with the type beside it (expressions.md, section "Compatible types"); otherwise the validator reports expression.typeMismatch at the place's pointer. A place whose value is a literal is checked by value.typeMismatch instead (section 6). A place whose declared type does not resolve, or a path whose type is any, is not checked. For a part's with, this is how a driven input's type is checked against what the parent can drive: a known type that cannot be accepted is reported, a value that may be null is not, and a driven value that does not conform at run time is handled as core.md, section "Parts: building apps from apps", says.
| Place (pointer) | Type it must be compatible with |
|---|---|
derive |
The entry's type. |
A stored entry's computed initial |
The entry's type. |
A sourced entry's source (the output of its operation) |
The entry's type. |
A view state entry's computed initial |
The entry's type. |
set to |
The type at the target path. |
append value |
The element type of the target. |
patch with |
The element type of the target when the step has where or the target ends in a selector, otherwise the type at the target. The with is a partial value: only the members it names are compared. |
Each member of the with of call, run, code, navigate, source, a navigation section and a part, and of a can input map literal; and a computed with as a whole |
The field's type in the target's field map (operation input, action input, code input, view input, or the type at the path a part's exported input names); a whole with, the closed map type of the field map. |
Each computed member of a capability config |
The config field's type. |
return |
The action's output, when it declares one. |
| Each node prop | The prop's type; boolean for hidden and disabled, string for variant. |
Each bind |
For a bindable prop, which the binding both reads and writes, the type at the target path MUST be compatible with the prop's type and the prop's type with the type at the target path. For an output, which the control only writes, the output's type MUST be compatible with the type at the target path. |
once |
string |
A navigation section's computed label, and a navigation group's computed group |
string |
A navigation section's computed count |
integer? |
allow, if, when, where, becomes, source.when, a require entry's that, and transition if and allow |
boolean |
An each step's expression, and the each.in of a node or a navigation section |
list<any> |
7.2 Worked cases#
In these cases goal is a state entry of type number, deposits of type finance:Transaction[] (a closed object type with id, amount, date and memo), policy of a closed catalog type expenses:Policy with a member version, and label an action input field of type string.
| Definition fragment | Diagnostic | Why |
|---|---|---|
/state/saved/derive: sum(state.deposits.map(d, d.amont)) |
expression. |
Transaction is closed and has no amont. |
An action allow: state.policy.versoin == 2 |
expression. |
Policy is closed. |
/state/total with type number and derive state.deposits.map(d, d.amount) |
expression. at /state/total/derive |
A list<number> is not compatible with number. |
A step { "set": "state.goal", "to": "=input.label" } |
expression. at .../to |
A string is not compatible with number. |
A step { "call": "bank.listTransactions", "with": { "since": "=state.goal" } } with since of type date |
expression. at .../with/since |
A number is not compatible with date, whose static type is string. |
A node prop "value": "=state.deposits" on a control whose value is a number |
expression. at .../props/value |
A list is not compatible with number. |
grants. with no request readSavings |
expression. |
grants names only the declared requests. |
{ "set": "state.lastDate", "to": "=input.label" } with lastDate of type date |
none | string is compatible with date; the value is checked when it is written. |
{ "set": "state.goal", "to": "=null" } |
none | null is not tracked. |
/state/half with type integer and derive state.goal / 2 |
none | number is compatible with integer. |
A bind of a date entry to a string? prop |
none | date and string are both strings. |
state.settings.theme with settings of type { "type": "object" } |
none | The map is open. |
/state/page sourced from an operation whose output is a map type, with type a different closed map type that names the same members |
none | The types are compatible; a read whose output does not conform to type fails at run time. |
8. State, writes and actions#
| Code | Severity | Rule |
|---|---|---|
state.cycle |
error | Derived entries MUST NOT read each other, directly or through other derived entries, in a cycle. |
state.sourceNotRead |
error | A state source MUST call an operation whose effect is read and that is not interactive. |
state.sourceNotPaged |
error | A state source that sets pages above 1 MUST call an operation that declares paging. |
state.notSourced |
error | The path of a refresh step MUST be state. followed by the name of a sourced entry, and nothing more. A declared entry that is not sourced, or a path longer than state.<name>, is state.notSourced; an undeclared name is reference. only; a selector is expression.syntax only. |
state.readonly |
error | Steps, bindings and exported inputs MUST NOT target a derived or sourced entry. |
state.internal |
error | A state entry with internal: true MUST NOT appear in exports.state or be named in an agent resources.include list. Naming one in resources.exclude is allowed. |
state. |
warning | A sourced entry whose operation's scope has sensitivity high SHOULD set sensitive, to true or to false. |
write.invalidTarget |
error | The target of set, append, remove, patch and bind MUST be state. followed by a declared stored entry; item in the steps of a collection flow; or view. followed by a state entry of the view, in an event handler or bind of a node of that view. Selectors may follow any name. |
write.notList |
error | The target of append, remove, and patch with where, and the value before each selector of a path, MUST be a list wherever its static type is known. |
write.sharedDirect |
error | A bind, and a set, append, remove or patch step written in a visual event handler (directly or nested in its if, each and onError steps), MUST NOT target a stored entry whose scope is shared. Shared state changes only through actions, which a handler runs with run. The steps of an action a handler runs are not affected. |
view.handlerStep |
error | A visual event handler MUST hold only set, append, remove, patch, let, if, each, navigate, refresh and run steps. A call, code, send, emit or return step in a handler, at any depth (also inside its if and each steps and the onError steps of its run steps), is reported. Outside effects, flow events and app events start in an action, which a handler runs with run. |
action.unknown |
error | run, can, a voice intent's action and an action:name trigger MUST name a declared action. |
action.cycle |
error | The static call graph that run steps form between actions MUST be acyclic. |
action.internal |
error | An internal action MUST NOT appear in exports.actions, in agent tools.include or tools.describe, or as a voice intent action. Naming one in tools.exclude is allowed. |
action. |
error | A run step MUST NOT target an action whose confirm is true or an object when the step is in a rule's do, in a flow's transition do, enter or exit, or in the steps of an action whose confirm is absent or false. Steps nested in if, each and onError count where their enclosing step is. A run in a visual event handler is not reported. |
action.waitsOnPerson |
error | A step that waits on a person, a call of an operation that is interactive or a run in a visual event handler of an action whose confirm is true or an object, MUST come before every step of its work that changes anything: a set, append, remove or patch of stored state, a send, an emit, a call of an operation whose effect is not read, or a run of an action whose steps can do any of these. Writes to view state in a visual event handler are not changes. Several steps that wait may stand in a row. Such a step MUST NOT be in a rule's do (a lifecycle rule's included), in a flow's transition do, enter or exit, or in an action any of those reaches with run. Steps nested in if, each and onError are judged on every path: a step that some path reaches after a change, a later pass of an each body included, is reported, and a path that ended with return or fail reaches nothing after it. A run whose action (an exported action of a part included) reaches such a step before it changes anything is reported at the run. A run that action. reports is not reported again. |
action.doneTooLong |
warning | A literal done.message SHOULD be at most 200 characters once cleaned to one line, as a host cleans it (core.md, section "Actions"): a host cuts a longer message. |
call.onceEffect |
error | A call step with once MUST call an operation whose effect is write or external. |
code.unknown |
error | A code step MUST name a declared code module. |
field.unknown |
error | A literal input object MUST name only fields its target declares. |
field.missing |
error | A literal input object MUST supply every required field of its target. A capability config is exempt: a required config field it leaves out is supplied when the capability is bound. |
9. Capabilities, grants and controls#
| Code | Severity | Rule |
|---|---|---|
contract.unknown |
error | Every alias:name contract reference MUST use an alias of uses.catalogs and name a contract of that catalog. |
contract.wrongKind |
error | Capabilities MUST reference capability contracts and nodes MUST reference control contracts. |
operation.unknown |
error | call steps and state sources MUST name a declared capability and an operation of its contract. |
event.unknown |
error | Event names MUST resolve: a bare trigger name to an event some emit step raises, alias.event to a capability event, action:name to an action, flow:name to a flow, refresh occasions to capability events, node on keys to control events, and voice announce keys to an event some emit step raises or to flow:name of a declared flow. |
event. |
warning | A core:list that handles move SHOULD name a moveGroup or be reorderable. With neither it takes no part in moving items, and no item is moved onto it. A list whose reorderable is an expression is not reported. |
grant.unknownTarget |
error | A grant request's capability or code MUST name a declared capability or code module. |
grant.unknownScope |
error | Every scope of a capability grant request MUST be declared by the contract. |
grant. |
error | Every name in a grant request's operations MUST be an operation or event of the capability's contract whose scope is one of the request's scopes. |
grant.uncovered |
error | Every used operation, and every capability event used in a rule trigger or a refresh.on list, MUST be covered (section 2). |
grant.eventWithheld |
warning | A capability event used in a rule trigger or a refresh.on list SHOULD be able to pass the where of at least one grant request covering it. It cannot when every such where reads an input field the event payload does not carry, because a condition that cannot be evaluated withholds the event (core.md, section "Grants"). A where that uses has or default is not reported. |
grant. |
error | For every used contract, each requires entry MUST be covered: some capability whose contract has the required contract's catalog id and name has grant requests that cover all the required scopes (section 2). |
code.noGrant |
error | Every code module MUST have a grant request naming it. |
egress.ungranted |
error | A control prop the contract marks remote MAY be set to a literal absolute http or https address only when some capability whose contract has the egress trait has a grant request that either carries no operations or names in operations an operation whose effect is read. A computed value, or a reference to content the host already holds, is not reported: the host settles it when it loads the content (core.md, section "Egress"). |
egress. |
error | When a remote prop is a literal absolute http or https URL and every granted egress capability has a literal origin, the URL's origin MUST equal one of them. |
trigger.noBackground |
warning | An every trigger that does not set foreground: true, and a flow after timer, SHOULD come with a grant request on a capability whose contract has the background trait; without one it runs only while a person has a surface of the app open. An agent's connection alone does not count. foreground: true states that running only then is intended. |
duration.invalid |
error | every, refresh.every, flow after keys, grant duration and rate.per MUST be durations longer than zero. |
prop.unknown |
error | Node props MUST be declared by the contract or be a common prop: variant, hidden, disabled. |
prop.missing |
error | Every required prop MUST be set in props or bound in bind. |
prop. |
warning | A node that sets iconOnly to true SHOULD set icon, when its control declares both. Without an icon the host shows the label. |
prop. |
warning | A core:text whose format is absent or plain SHOULD NOT have a literal value that is plainly written in Markdown: a pair of ** around words, a link written [words](http...), [words](https...) or [words](mailto...), a line that starts with # to ### and a space, or two or more lines that start with -. A host shows such a value with its markup. A lone asterisk, a minus sign or brackets alone are not reported, nor is a value computed by an expression. Reported at the value. |
prop. |
warning | A core:list that names a moveGroup SHOULD handle move. Without a handler it takes no part in moving items, and its items cannot be moved. |
prop.moveGroupAlone |
warning | A core:list that takes part in moving items (it names a moveGroup and handles move) SHOULD share its group with another core:list of its view: one whose moveGroup is the same literal or an expression. A list whose own moveGroup is an expression, a list repeated by each or drawn in a slot once per item, and a reorderable list, whose items move within it, is not reported. |
prop. |
warning | A core:list that is reorderable SHOULD handle move. Without a handler it takes no part in moving items, and a person cannot put its items in order. A reorderable that is the literal false is not reported; one that is an expression is. |
prop.moveListUnnamed |
warning | A core:list that takes part in moving items SHOULD set label to an expression or a text that is not blank: hosts name the list by it where they offer to move an item to it. |
bind.invalid |
error | bind MUST name a prop the contract marks bindable, or an output. |
slot.unknown |
error | slots MUST name slots the contract declares. |
slot.missing |
error | Every slot the contract marks required MUST be filled. |
node.children |
error | children MUST respect the contract: none for none, at most one for one. |
view.unknown |
error | start, every navigation section's view and every navigate target other than back MUST name a declared view. |
view. |
error | A navigation section without with MUST name a view whose input has no required field, and two sections that have neither each nor with MUST NOT name the same view. Reported at the section's view; for a view named twice, at each such section after the first. A section's with is checked as a navigate step's is (field.unknown, field.missing, value.typeMismatch). |
view. |
warning | The first node a view's body draws SHOULD NOT be a core:heading whose value says what the view's title says: two literal texts equal after trimming and without regard to case, or the same expression. A host draws the title as the heading of the page, or of the card an app of one view is drawn as (core.md section 12.2), so the words would show twice. The first node drawn is the body, or, while that is a core:stack, its first child, followed through first children that are stacks. Reported at the heading. |
view.tabUnnamed |
warning | Every child of a core:tabs SHOULD name its tab: a control whose contract's labelProp is set by the node to an expression or a text that is not blank (or has such a default), such as a core:group with a title, or a part view whose title is set. A tab with nothing to name it is captioned by its position alone. Reported at the child. |
9.1 Assets#
These checks apply to the assets of a definition (core.md, section 12.5). The rules on the bytes apply only to an entry that carries data; an entry without it is checked by the schema alone. An asset reference is a literal string that starts with asset:, the whole value of a prop that the contract marks remote or a string anywhere inside such a value. A string in such a prop that is an expression could name any asset.
| Code | Severity | Rule |
|---|---|---|
asset.dataInvalid |
error | An asset's data MUST be base64 in its one form: the standard alphabet, with padding, no line break and no other character, and zero in the bits that padding leaves unused. schema |
asset.digestMismatch |
error | The digest of the bytes of an asset's data MUST equal its digest. Reported at digest. |
asset.unrecognized |
error | The bytes of an asset's data MUST be a PNG, JPEG, WebP or GIF picture whose header can be read as core.md section 12.5 sets out. Reported at data. |
asset.typeMismatch |
error | The bytes of an asset's data MUST be a picture of the type its type gives. Reported at type. |
asset.tooLarge |
error | The picture an asset's data holds MUST be at most 4096 pixels wide and at most 4096 pixels high, as its header gives them. Reported at data. |
asset.sizeMismatch |
error | An asset's width and height, where given, MUST be the size its picture shows at: those its header gives, swapped when its EXIF orientation turns it a quarter (core.md section 12.5). Reported at the member that differs. |
asset.unknown |
error | An asset reference MUST be asset: followed by the name of an entry of the definition's own assets. Reported at the string. |
asset.unused |
warning | Every asset SHOULD be named by an asset reference. It is not reported when any remote prop of the definition holds an expression, which could name it. |
document.beyondFloor |
warning | A definition, as JSON without insignificant white space and without the data of its assets, SHOULD be at most 2,621,440 bytes in UTF-8, which every host accepts (core.md, section 18.1). Reported at the document. |
asset. |
warning | A definition SHOULD have at most 64 assets, which every host accepts. Reported at assets. |
asset. |
warning | The data of an asset SHOULD be at most 1,048,576 characters, which every host accepts. Reported at the data. |
asset. |
warning | The data of all assets together SHOULD be at most 2,621,440 characters, which every host accepts. Reported at assets. |
included. |
warning | included SHOULD hold at most 16 definitions and at most 17 design systems, which every host accepts (core.md, section 18.1). Reported at included, once for each kind beyond. |
included. |
warning | The carried copies, each as JSON without insignificant white space and without the data of its assets, SHOULD be at most 2,621,440 bytes in UTF-8 together, which every host accepts. Reported at included. |
included. |
warning | The carried copies SHOULD have at most 64 assets together, which every host accepts. Reported at included. |
included. |
warning | The data of an asset of a carried copy SHOULD be at most 1,048,576 characters, which every host accepts. Reported at the data. |
included. |
warning | The data of all assets of the carried copies together SHOULD be at most 2,621,440 characters, which every host accepts. Reported at included. |
The size of the definition itself (document.beyondFloor) does not count included, and the rules above on assets apply to the definition's own assets only: the pictures of a carried copy count toward the sizes of included.
A message about an asset never repeats a value of the document, such as any part of a data text or of a reference: it names the asset by its key, or the place by its pointer.
9.2 Texts in several languages#
These checks apply to a definition's localization (core.md section 12.6) and to every use of its keys: each call of t in an expression (expressions.md section 8.7), wherever an expression, a dynamic value or a path selector stands, and each fixed-text reference, a value that is exactly =t('key') at one of the fixed-text places core.md section 12.6 lists. The default table is the member of strings named by default. A translation is the table of any other language. An entry's blanks are the blank names of all its texts, its forms together; the names an entry takes are its blanks and its by.
| Code | Severity | Rule |
|---|---|---|
localization. |
error | default and every key of strings MUST be a language tag in its one spelling: it matches ^[a-z]{2,3}(-[A-Z][a-z]{3})?(-([A-Z]{2}\|[0-9]{3}))?$, and its language is not und and not an old code of table aliases (core.md Appendix A). Reported at the tag. The message SHOULD give the valid spelling where there is one: en-US for en-us or en_US, he for iw. |
localization. |
error | When strings is present, it MUST have a member for default. Reported at strings. |
localization. |
error | Every entry MUST be a well-formed text (expressions.md section 8.7), or forms whose by is a blank name, which have an other form, whose form keys are not empty, each key that begins with = being = and a finite number exactly as string writes it, and whose forms are well-formed texts. Reported at the entry, or at the form at fault. |
localization. |
error | Every t call and every fixed-text reference MUST name a key of the default table. A definition with no strings, or with no localization, has no keys, so every use is reported. Reported at the expression or the place. The message SHOULD name the nearest keys by spelling. |
localization. |
error | A t call MUST give a value for exactly the names the entry of its key in the default table takes: none that the entry does not take, none of them left out. It MUST NOT give a value whose static type is boolean for a name the entry shows in a text that such a value could choose (a blank other than by shown in any form; the by itself shown in the form true, the form false or, where either is missing, other). Reported at the expression. |
localization. |
error | A translation's entry of a key the default table has MUST NOT show a blank, nor choose its form by a by, that the default entry does not take. A translation MAY leave out a blank of the default entry. Reported at the translation's entry. |
localization. |
error | The key of a fixed-text reference MUST be, in every table that has it, a text without blanks that is not empty. Reported at the place. |
localization. |
warning | Every translation SHOULD give a text in its own language for every key of the default table: its own entry, or that of a table of the same language and script earlier in its text chain (core.md section 12.7), including the default table when that is of the same language and script. Reported once for each translation, at its table, with the count and the first five keys. |
localization. |
warning | Every key of a translation, and of notes, SHOULD be a key of the default table: no use can name another. Reported once for each translation, at its table, and once for notes, with the count and the first five keys. |
localization. |
warning | Every key of the default table SHOULD be named by a t call or a fixed-text reference. Reported once, at the default table, with the count and the first five keys. It is not reported when an expression or a path of the definition does not parse, since the uses it holds are not known. |
localization. |
warning | A translation's text SHOULD differ from the default table's text of the same key. Only a default text of more than 3 code points that holds a letter (Unicode category L) is compared, and only with a translation's entry that is a text. Reported once for each translation, at its table, with the count and the first five keys. |
localization. |
warning | A tag whose language is zh or sr SHOULD name its script (zh-Hans, zh-Hant, sr-Cyrl, sr-Latn): without one, the script follows the region. Reported once for each such tag, at its table, or at default when no table has it. |
localization. |
warning | A value at a fixed-text place that begins with =t( SHOULD be exactly a reference =t('key'): anything else is shown as its characters. Reported at the place. |
localization. |
warning | A definition without localization whose literal texts people see mostly begin in a right-to-left script SHOULD declare its language ("localization": { "default": "ar" }), so that a host lays the app out right to left. The texts counted are the literal meta.name and meta.description, view titles, navigation section labels, confirm and done messages of actions, and node props whose declared type is a string with no enum, const, pattern, format or known values, each counted when it has a first strong character (expressions.md section 8.7). Reported at the document when at least 5 are counted and more than half of them have a right-to-left first strong character. |
localization. |
warning | strings SHOULD have at most 64 languages, which every host accepts (core.md section 18.1). Reported at strings. |
localization. |
warning | A table SHOULD have at most 2,000 keys, which every host accepts. Reported once, at the first such table. |
localization. |
warning | A text of a table SHOULD be at most 2,000 code points, each form counted alone, and an entry SHOULD have at most 24 forms, which every host accepts. Reported once, at the first such entry, with the count of the others. |
Order. These checks run with the other checks of a definition, after the schema. A use is checked against the default table only when that table exists: when strings lacks it, localization.defaultMissing is reported once and no use is reported. The values of a t call are checked only when its key is in the default table and the default entry is well formed, and a translation's entry only when both it and the default entry are well formed, so that one mistake gives one diagnostic. The warnings on translations and on unused keys follow, once every use has been found.
Texts read by other checks. The checks that read a literal text, such as the type of a literal prop with its length limits (a chart's unit, the label of its goal), a literal initial, input member or written value against its type (value.typeMismatch), Markdown in a plain core:text (prop.markdownInPlainText), the length of a done message (action.doneTooLong) and a heading that repeats its view's title (view.headingRepeatsTitle), also read each language's text where a value, or a string within it, is exactly the expression t('key') with no values and the key's entry in that language's own table is a text without blanks. They read the text as it is shown, {{ as { and }} as }, and a diagnostic they report for it names the language. At a fixed-text place that holds a reference, every rule on the place reads the text of each language the same way: an asset's credit is one line of at most 300 code points in every language, reported as schema.invalid at the place.
Without the schema. A tool that runs these checks on a document without validating it against the schema also misses what only the schema holds: the shape of localization (no member but default, strings and notes; an entry is a string or an object with exactly by and forms; every form a string), the pattern of a key of a table and of notes, and a note of 1 to 300 characters. The language tag is not in the schema: localization.tagInvalid is its only report.
10. Flows, exports and surfaces#
| Code | Severity | Rule |
|---|---|---|
flow.unknown |
error | A send step and a canSend call MUST name a declared flow. |
flow.unknownState |
error | A flow's initial and every transition to MUST name a state of that flow. |
flow.unknownEvent |
error | A send step and a canSend call MUST name an event that some state of the flow handles. |
flow.keyMismatch |
error | A send step and a canSend call MUST carry a key exactly when the flow is a collection flow. |
flow. |
error | over.collection MUST be a path to stored state that is a list wherever its static type is known. |
flow.fieldWrite |
error | A step or binding MUST NOT write the field of a collection flow where this can be seen from the definition: a target path that is the flow's collection path followed by a selector and .field (and possibly more names); in the flow's own steps, a target path item.field; a patch of the collection, of an element of it selected by a selector, or of item, whose with is a JSON object or a map literal with a member named field; or an append to the collection whose value is a JSON object with a literal member field that is not the flow's initial. |
flow.unreachable |
warning | Every state of a flow SHOULD be reachable from initial. |
export.unknown |
error | exports MUST name existing state entries, actions and views, events some emit step raises, and inputs pointing at declared state entries. |
export.notStored |
error | Every exported input MUST be a path into a stored state entry. |
surface.unknownName |
error | Agent tools lists and describe keys MUST name actions (an exclude list MAY name internal actions), resources lists MUST name state entries (an exclude list MAY name entries that are not exposed), and events.include MUST name emitted events or flow:<name> of a declared flow. An include list MAY also name part.name for an action, state entry or event the part exports. |
voice.unknownSlot |
error | Every {slot} placeholder in a voice example MUST name an input field of the intent's action. An intent without an action has no slots. |
11. Catalogs#
| Code | Severity | Rule |
|---|---|---|
scope.undeclared |
error | Every operation and event scope MUST be declared in the contract's scopes. |
contract. |
error | labelProp MUST name a declared prop; degradeTo MUST name another control contract of the same catalog, or, written alias:contractName, a control contract of a catalog this catalog uses, with alias a key of its uses.catalogs; deprecated. MUST name another contract of the same kind in the same catalog. |
contract. |
error | A requires entry's contract MUST name a capability contract of the same catalog, or, written alias:contractName, of a catalog this catalog uses, with alias a key of its uses.catalogs; and its scopes MUST be scopes that contract declares. |
contract. |
error | An operation that declares paging MUST have an output that is a map type naming both the paging.next and the paging.items member; the member paging.items names MUST be a list; and paging.cursor MUST name an optional field of its input whose type is string or string?. An operation with no output, or whose known output type is not a map, is reported. An output type that does not resolve, or a member whose static type is not known, is not checked further. |
contract. |
error | A capability whose traits include background or egress MUST NOT have a scope with consent: "use". Such a scope MUST NOT be the scope of an event, and every operation under it that is not interactive MUST have effect: "read". Reported once for each scope, event or operation at fault. |
contract. |
error | A capability contract with the egress trait MUST declare a config field named origin. schema |
contract. |
error | A control output MUST NOT share a name with a prop of the same control. |
contract. |
warning | When a control has a bindable prop value and a change event, the event payload SHOULD have a field value of the same type. |
The type, value and name rules of sections 4 and 6 also apply to catalogs: a type reference resolves to a name in the catalog's own types or, written alias:TypeName, to a type of a catalog it uses, with alias a key of its uses.catalogs (type.unresolved otherwise), and defaults conform to their field types. uses.catalogNotFound (section 5) applies to a catalog's uses.catalogs. A reference through an alias whose catalog did not resolve is not checked further (section 2).
12. Design systems#
| Code | Severity | Rule |
|---|---|---|
design.missingToken |
error | A design system MUST define the color tokens surface, text, textMuted, outline, accent, onAccent, neutral, info, success, warning, danger and category1 to category8, and the space tokens small, medium and large. schema |
design. |
error | A modes entry MUST override only tokens that the base tokens define, group by group. |
design. |
error | When the catalog a variants key names can be resolved, the key MUST name a control contract of it. |
design. |
error | A variant preset MUST set only props the control contract declares; literal values MUST conform to the prop types (value.typeMismatch). |
13. Conformance fixtures#
conformance/0.2/semantic/ holds fixtures for these checks:
valid/holds definitions that produce no diagnostic at all.invalid/holds definitions (*.oad.json), catalogs (*.oadcatalog.json) and design systems (*.oaddesign.json) that each validate against their schema and break exactly one rule.invalid/manifest.jsonlists{ "file", "code", "pointer", "violates" }for each, whereviolatesis a sentence that says what the file breaks (informative, like a message); a conforming validator reports exactly one diagnostic for the file, with that code and pointer.registry/holds the catalogs, included definitions and design systems the fixtures resolve against, beside the core catalog, which every validator has. A fixture that carries copies in itsincludedresolves against them first: where the registry also holds a version that fits, the carried copy is still the one checked.
Every code in this chapter has at least one invalid fixture, except document.invalid, schema.invalid and the rules marked schema, which no schema-valid file can break, and document.beyondFloor, asset.dataBeyondFloor, asset.totalBeyondFloor, included.sizeBeyondFloor, included.assetDataBeyondFloor and included.assetTotalBeyondFloor, whose fixtures would each be megabytes long. document.version is tested with a file whose version marker is 0.1. The static type rules of section 7.1 have invalid fixtures for each kind of place in its last table, and valid fixtures for the cases that section 7.2 shows are not reported.