# Conventions

## Naming

| Thing                        | Convention                                             | Example                        |
| ---------------------------- | ------------------------------------------------------ | ------------------------------ |
| Group, app, registration key | No `.`; PascalCase for declarations, camelCase for app | `core`, `UserProfile`          |
| Properties                   | Describe the _value_, not the field                    | `UserId`, `Email`, `Timestamp` |
| Schema fields                | camelCase                                              | `externalCustomerId`           |
| Operations                   | Verb then noun                                         | `CreateUser`, `ListUsers`      |
| Events                       | Past tense                                             | `UserCreated`                  |
| Policies                     | Describe the requirement                               | `CurrentUser`, `CanRead`       |

Packs derive every casing (`kebab`, `snake`, `pascal`, `camel`) from the semantic name, so choose a name that reads well as plain words. See [Naming](/authoring/vocabulary/naming) for the formal rules.

## Structure

- **One group per bounded area** (`users`, `billing`) and **features** inside it when you need a finer registration scope. A declaration belongs to one group and at most one feature.
- **Shared values in a `shared` group** (`Id`, `Email`, `Timestamp`) so every schema reuses one definition.
- **Separate the stored shape from the API shapes.** Declare one `entity` schema with a `storage` facet, then derive `UserRead`, `CreateUserRequest`, `UpdateUserRequest` and `UserQuery` with projections instead of copying fields.
- **Give operations a `role`** (`create`, `detail`, `list`, `update`, `delete`). Packs use roles to choose HTTP verbs, status codes and handler shapes.

## Modelling habits

1. **Mark system fields** (`.system()`): ids and timestamps the client must not send.
2. **State query ability on the field** (`.query({ filter: ["equal"], sort: true })`) instead of in the API layer.
3. **Prefer registered properties to inline types** so constraints live in one place.
4. **Say what is sensitive** (`.sensitive()`), so packs can redact it in logs and docs.
5. **Declare failures and events** an operation can produce; packs map them to error responses and messages.
6. **Keep policies semantic.** A policy says "needs a current user with an id"; it is not middleware.

## What not to do

- Do not put framework concepts (decorators, column types, controllers) in contracts.
- Do not reference a raw definition: register it first.
- Do not encode behaviour in names that packs must parse.
- Do not rely on file order or hidden defaults. If a pack needs a fact, state it.
