# Versions, proposals and reviews

> How the map changes, who approves, and how every version is kept.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://cases.docs.sypnia.com/contract/versions-and-reviews/

For agents: Versions: each approval creates an immutable map version (v1, v2…) with author, approvers, date and a diff; a version made from files keeps each file's text as written (pull and export give it back byte for byte); a case a proposal changed is written in the format's compact style. From the CLI: cases pull [--version N], cases push (files as a draft proposal), cases propose --title [--reviewers], cases diff v3..v4. Proposals: changes against the latest version (add: area from change.area, case.area, the area of map.yaml that lists it, or the only area, and listed there; change: replaces only the fields it gives, null removes one; retire: keeps the case with status retired), optionally a new map.yaml or navigation.yaml, with a title, comments per case or field, named reviewers. Drafts (uploads from code) become open when someone asks for reviews. Merge: required_approvals.count (1 by default, set per map) approvals from owners or approvers plus every required named reviewer; the author may approve their own proposal; a proposal on an older version merges when no case it touches changed since its base, else 409 version_conflict (also when another approval won the version number); approvals of one proposal serialized by a row lock. Roles: owner, editor, approver, reviewer (plain level, comments, approves when named); project tokens act as editors and never approve. Sypnia Cloud: owner → owner, admin → approver, developer → editor, viewer → reviewer; members managed in the organization, Cases invites reviewers only. In a repository, a pull request on cases/ is a proposal; in Sypnia Cloud both stay in sync.

## Versions

Every approval creates a **version** of the map: `v1`, `v2`, `v3`… A version never changes. It keeps who proposed it, who approved it, when, and the difference from the previous one. The latest approved version is the scope.

A version made from files keeps the text of each file as people wrote it, comments and order included: `cases pull` and the export give it back byte for byte. A case that a proposal changed field by field has no text of its own, so it is written in the format's compact style (small mappings and lists on one line).

```bash
npx @sypnia/cases pull                 # the approved version into cases/ (--version 3 for another)
npx @sypnia/cases diff v3..v4          # what changed between two versions
npx @sypnia/cases push                 # cases/ as a draft proposal
npx @sypnia/cases propose --title "Gift cards" --reviewers owner@la-espiga.co
```

## Proposals

A change to an approved map is a **proposal**: a title, the changes, and a conversation. Each change is one of three:

| Change   | What it does                                                                                                                                                       |
| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `add`    | a new case. Its area comes from the change, from the case, from the area of `map.yaml` that lists it, or from the map's only area; the case is listed in that area |
| `change` | replaces only the fields it gives; a field set to `null` is removed                                                                                                |
| `retire` | keeps the case with `status: retired`, so its events and its history keep their meaning                                                                            |

A proposal may also bring a new `map.yaml` or `navigation.yaml`, and name its reviewers at once.

- **Comments per case.** A reviewer comments on a case, a step or a failure, in plain words. A case can also be commented on outside any proposal.
- **Drafts.** A map uploaded from code arrives as a draft proposal ([From code](https://cases.docs.sypnia.com/format/from-code)). A draft becomes open when someone asks for reviews.
- **The check runs on it.** A proposal shows whether it makes the code in scope again, or what it would leave unbuilt.
- **Merged into a new version** when approved.

## What a merge needs

- **Approvals from owners or approvers**: as many as the map asks for (`required_approvals.count`, 1 by default; owners set it per map).
- **Every required reviewer named on the proposal.** You name reviewers by e-mail; anyone who is not a member is invited to the workspace as a reviewer, reads the plain level and approves that proposal.
- The author may approve their own proposal.

Approvals of one proposal take turns, and each role is checked again inside the approval's transaction. A proposal made on an older version merges on its own when no case it touches changed since its base. Otherwise, or when another approval just took the version number, the answer is `409 version_conflict`: rebase the proposal on the latest version and approve again.

## In a repository

In a repository, a **pull request that changes `cases/`** is a proposal, and its merge is a version. Sypnia Cloud keeps both in sync: a proposal approved in the editor becomes a commit; a pull request opened in Sypnia Git or GitHub appears as a proposal in the editor.

## Who can do what

| Role               | Reads           | Proposes      | Approves                 | Deliveries and dead letters |
| ------------------ | --------------- | ------------- | ------------------------ | --------------------------- |
| Owner              | yes             | yes           | yes                      | yes                         |
| Editor             | yes             | yes           | no                       | yes                         |
| Approver           | yes             | yes           | yes                      | yes                         |
| Reviewer (invited) | the plain level | comments only | if named on the proposal | no                          |

Owners also manage members, a map's settings, its Telemetry link and its project tokens. A project token acts as an editor of its map and never approves.

In Sypnia Cloud, a workspace is a Sypnia organization and its roles map onto these: owner → owner, admin → approver, developer → editor, viewer → reviewer. Members and their roles are managed in the organization; Cases invites reviewers only ([Security](https://cases.docs.sypnia.com/security#in-sypnia-cloud)).
