1. Files and the workspace
A contract workspace is a directory of YAML files with one entry file, workspace.yaml; the workspace root is that file’s directory. A workspace with a single api may omit it; the CLI then takes the api file directly, and the root is the api file’s directory. A contract whose files reach above that directory (extends: ../shared/base.yaml) needs a workspace.yaml at or above every file it reads.
workspace: apis: tasks: ./tasks/api.yaml tasksService: ./tasks-service/api.yaml shared: ./shared/base.yaml imports: storefront: { package: '@acme/contracts', version: 2.3.0, api: storefront, integrity: sha256-Qm9vY... }workspace.apismaps each api name to its api file. The names must equal each file’sapi.name. All apis of a workspace compile together, which is howrelaysreaches a sibling api (FR-8).workspace.sharednames a file with the keys of a base, which every api of the workspace builds on, before its own base (section 2). It holds what several apis share: schemes, identities, common schemas, and the rights and scopes their field marks name.workspace.editorSchemasnames the directorycompile --editor-schemaswrites to, relative to the root (.seampact/schemasby default, section 3).workspace.importsnames an api held in a pinned contract bundle, so arelayscan target it without its sources. An entry takes one source form of the app config’ssources(ADR 0011:packagewithversion,release, orgit),api, the api’s name inside the bundle, andintegrity, which is required. The bundle passes ADR 0011’s pinned-bundle check before its IR is read; a missingintegrityfails and prints the actual value, so pinning is a copy.
There are five kinds of file. The loader knows each by its top-level keys.
| File | Top-level keys | Reached by |
|---|---|---|
| workspace | workspace |
the CLI |
| api | api, extends, packs, surfaces, any catalogue, conventions, formats, extensions, lint |
workspace.apis |
| base | any catalogue, packs, conventions, formats, extensions, lint |
extends from an api, or workspace.shared |
| pack | pack, any catalogue, conventions, formats, extensions, lint, derive |
packs from an api or base, extends from a pack |
| fragment | whatever the include site expects | $include or a file $ref |
The catalogues are schemas, enums, scalars (named formats, ADR 0003 section 8), errors, natures (error natures, section 11), schemes, headers (identity headers, section 9), identities, rights, rules, requirements (named requirement items, section 9), scopes, buckets, services and pagings (section 14). formats (section 13) is keyed by name like a catalogue. Each maps a name to one declaration. Everything a contract references by name lives in one of them.
Paths in extends, packs, $include, $ref and $file are relative to the file that contains them, use forward slashes, must stay inside the workspace root, and must match the case of the file on disk. The last two rules keep compilation identical on case-insensitive file systems and stop a contract from reading files outside its repository.