# Annex S: operation design and self-description rules (`atip/2`, 2.0.0-draft)

Normative at L1, where `spec/core.md` 4.5 and 12 refer to it. S1 constrains the operations and arguments a tool
exposes on any binding; S2 lists the core rules every `schema` answer satisfies beyond `schema/catalog.schema.json`.
Command-line design rules and CLI-specific catalog rules live in `spec/binding-cli.md` 9.

## S1. Operation and argument design

1. Actions are verbs; read-only views MAY be nouns with effect `read`. No argument changes an operation's effect class
   or makes it another action with its own arguments; such a mode is its own operation. Views of the same data
   (`fields`, paging), waiting (`wait`, `timeout`), preview and commit (`commit`, `planDigest`), dry run (`dryRun`),
   and a declared output variant are not modes.
2. Identifier arguments are bare camelCase nouns (`change`, `run`, `finding`); no argument name ends in `Id`
   (`spec/core.md` 4.1.4).
3. Within a tool an argument name has one value type and meaning across operations; only `required`, the default and a
   subset of a shared enum may differ. This holds tool-wide for a shared argument (`spec/core.md` 12.3), whose name
   an argument of an operation's own keeps with its value type, and for a `boolean` argument (or one with `cli.count`);
   for any other argument it holds within a group: the operation id without its final word, the verb (a one-word id's
   group is the root). Across groups a name MAY mean different things, and on the CLI the two sides then use different
   `cli.valueName` placeholders (`spec/binding-cli.md` 9.1); the same name with the same `cli.valueName` (or default
   value name) means one thing in every group.
4. An unknown operation, argument or enum value is refused before any effect, with `expected` and `suggestions`;
   nothing is auto-corrected. An argument an operation cannot honour with the others is refused by pointer rather than
   being ignored.
5. A renamed or removed operation or argument is not kept as an alias; a removed spelling MAY be recognised only to
   refuse it (`OPERATION_NOT_FOUND` or `INPUT_INVALID`) with the replacement as `hint`.
6. Times are RFC 3339 (a bare `YYYY-MM-DD` MAY mean UTC midnight). A duration string is one or more `<integer><unit>`
   pairs, units `ms`, `s`, `m`, `h`, `d` in decreasing order (`90s`, `1h30m`); a bare integer in a duration string
   means seconds.

## S2. Self-description rules

Every `schema` answer satisfies the rules below. An operation's full argument set is its own argument objects, the
shared tree arguments and reserved arguments it names by string, and the reserved arguments its document implies
(`fields` when an output declares `fields`, `spec/core.md` 12.5.1).

1. A group's children extend its `operation` id by one `_`-separated word (`spec/core.md` 4.1.1).
2. Every `schemaRef` and `eventRef` names a member of `schemas` in the `schemas` answer (`spec/core.md` 12.6), by
   membership (`false` is a valid schema). The `schemas` answer holds exactly the schemas the refs reach and the
   derived `Input` schema under the name `Input` (which no `schemaRef` or `eventRef` takes), plus `rejects` when the
   operation declares `validators`. Every member compiles under JSON Schema draft 2020-12; no two outputs share a
   `schemaRef`.
3. The `Input` schema in the `schemas` answer equals the schema derived from the operation's full argument set
   (`spec/core.md` 4.2.2, 12.6): `{type: "object", additionalProperties: false, properties, required?}`, with one
   property per argument from its `valueType`, `repeatable`, `possibleValues`, `domain`, `help` (as `description`) and
   `default`, and `required` listing the required arguments.
4. Defaults, `in` values and domains are valid: an `enum` default is in `possibleValues`; an `in` value in a constraint
   is a valid value of its argument within its `domain`, never on a `boolean` argument (or one with `cli.count`); a
   `domain` keeps to its `valueType`'s profile and bounds (`spec/annex-domains.md`) and holds for any non-null
   default.
5. Every argument name and `code` of a constraint resolves (`code` in `errors` or implied); no relation is stated
   twice; an operation document lists neither an implied code nor an implied argument (`spec/core.md` 12.5.1).
6. `idempotency` is present exactly for `write` and `destructive` operations; `async` is present only on an operation
   whose `async.monitor` names a `read` operation in the same catalog.
7. Outputs are told apart pairwise by `when` (or `batch` on the CLI, `spec/binding-cli.md` 9.2); at most one has
   neither.
8. A listed reserved argument (`spec/core.md` 4.3.1) has its fixed shape (`commit`, `all`, `dryRun`, `wait` are
   `boolean`; `planDigest`, `cursor`, `timeout` are `string`; `idempotencyKey` is `string` with the pattern `^[!-~]{1,255}$`; `limit` is
   `integer` with `minimum: 1`; `fields` is repeatable `string`). No operation defines an argument named `json`, `input`, `help` or `version`.
9. Argument names are unique within an operation's full argument set.
10. An output's `fields` is consistent: its cut nodes are projectable (`spec/annex-fields.md` F5); `records` is `""`
    or leads through declared object members; `default` ⊆ `paths`; `keep` and `paths` are disjoint; every path names a
    declared member and goes through arrays only with `[]`.
11. Every entry of `examples` in an operation document is an input document that validates against the operation's
    derived `Input` schema and satisfies every declared constraint and validator (`spec/core.md` 12.5).
12. A validator names arguments of the operation; its `code` is in `errors` (or implied) with `refused: true` in the
    error registry; each entry of `rejects` in the `schemas` answer is a non-empty list of input documents (one list
    per validator, in the operation document's order) where every document validates against `Input`, satisfies every
    declared constraint, and is not in `examples`.
13. In an `errors` answer a code appears once, a core code has its fixed `refused` and `retryable` (`spec/core.md`
    6.4.1), a reason appears once within its code, and every non-core code follows the code grammar and matches its
    condition's `refused` and default `retryable` (`spec/core.md` 6.2); in a `warnings` answer a code appears once.
14. A field path writes a member in brackets exactly when its name is not an identifier; a map-key path extends a
    declared map path by one key (`spec/annex-fields.md` F1, F3).
15. A document carries only what its declared minor defines (`spec/core.md` 13.5), and no member has its default
    value (`spec/core.md` 12.5.2). Every string entry in an operation's `arguments` names a shared argument in
    `tree.arguments` or a reserved argument the document does not imply; every shared argument in `tree.arguments` is
    named by at least one operation; and a string reference and an object never give the same argument twice.
16. When the tree declares `pathShape`, no operation id has more words than `pathShape` has labels (`spec/core.md`
    4.1.1).
17. On a binding without a shared file system (always on HTTP, and on MCP unless served over stdio), no operation in
    the catalog has an argument with `valueType: "path"` (`spec/core.md` 12.2.2). On every binding other than the
    CLI, no argument in the catalog carries `cli` (`spec/core.md` 12.5.1).
18. Every JSON Schema a catalog publishes, in outputs, events, domains and the `schemas` answer, stays within the
    subset of draft 2020-12 that tools such as zod read: no `if`, `then` or `else`, no `unevaluatedProperties` or
    `unevaluatedItems`, and no `dependentRequired`, `dependentSchemas` or `dependencies`. A conditional rule is a `oneOf` of closed
    branches.
