livery.workshop._schema¶
livery.workshop._schema ¶
Each contract's JSON Schema, composed from its owners' keys, and its judge.
Every key a contract may have is declared as a record
(livery.workshop._contract_keys.Declared): the base's own, and each
installed extension's from its declaration file. The records compose
into one JSON Schema per contract, for the base and the extensions the
root contract lists. The contract judge validates a contract against
that schema, in its own words, and fm sync writes it under
.workshop/schema/, where the composed .taplo.toml points Taplo,
the language server behind an editor's TOML support: the judge and the
editor read one statement of each contract's shape.
A key's types become JSON Schema types, its values an enum and its
doc the description; a list of strings with values takes each of
them at most once. A table whose keys the author names (* in
a declared path) takes additionalProperties with the entry's
schema, and a key the table declares by name wins over that entry;
every other table refuses a key it does not declare. A key of an
installed extension the root does not list stays in the schema as a
key that takes no value, carrying its owner, so the judge and the
editor both name the extension to list.
Functions:
| Name | Description |
|---|---|
compose |
The JSON Schema of contract for the base and the listed extensions. |
composed |
|
contract_of |
Which contract the file at relative is; None for a file that is no contract. |
judged_by |
The line naming the schema the file at relative is judged by; empty for none. |
schema_files |
Each contract's composed schema for root, by its path under the root. |
problems |
Each refusal data earns against schema, in the contract's order. |
Attributes:
| Name | Type | Description |
|---|---|---|
DIRECTORY |
|
|
FILES |
dict[ContractKind, str]
|
|
DRAFT |
|
|
OWNER |
|
|
UNLISTED_BY |
|
FILES
module-attribute
¶
FILES: dict[ContractKind, str] = {'root': 'workshop.json', 'package': 'package.json', 'extension': 'extension.json'}
compose ¶
The JSON Schema of contract for the base and the listed extensions.
listed holds the names the contract's lists name the extensions by,
the base among them; None takes every installed owner as listed. A
key of an owner they leave out says which lists would take it.
The owners in livery.workshop._contract_keys.ALWAYS, the base
and the tool store, count as listed in every workspace. The
extension contract is the base's and the tool store's alone,
since an extension declares keys in a workspace's contracts and
never in another extension's file: composing it reads no other
owner's declarations, which a mount would otherwise read for every
installed extension.
Source code in packages/workshop/src/livery/workshop/_schema.py
composed ¶
compose, once per set of declarations: what the judge validates against.
The judge reads the composition the schema files are written from, never the files, so a file written before an extension was installed or listed cannot misjudge a key until the next sync.
Source code in packages/workshop/src/livery/workshop/_schema.py
contract_of ¶
contract_of(root: Path, relative: Path) -> ContractKind | None
Which contract the file at relative is; None for a file that is no contract.
The root's workshop.toml, a package's beneath packages/, or
any extension.toml.
Source code in packages/workshop/src/livery/workshop/_schema.py
judged_by ¶
The line naming the schema the file at relative is judged by; empty for none.
The file under .workshop/schema/, and the owners whose keys it
holds: the base and the tool store, then the installed set, in
composition order. An extension.toml is judged by the base's
and the tool store's keys alone.
Source code in packages/workshop/src/livery/workshop/_schema.py
schema_files ¶
Each contract's composed schema for root, by its path under the root.
Source code in packages/workshop/src/livery/workshop/_schema.py
problems ¶
Each refusal data earns against schema, in the contract's order.
An unknown key names its table, the keys the table takes and the nearest spelling; a key of an extension the contract's lists leave out names the extension and the list that would take it; a value of the wrong type names what the key takes; a value outside its set names the set and the nearest. A key that takes any value is judged by its reader, and nothing beneath it here.