# Part VI. History

A model's history is kept as git keeps code: content-addressed objects, trees that mirror the folder, versions that point at a tree and at the versions before them, and named refs. Two lines of work merge by record and by field, never by text.

The requirements of sections 1 to 5 apply to an implementation that keeps versions of a model (the *version store* class in [Conformance](https://openeik.org/spec/0.5/conformance)), and those of section 6 when it exchanges versions with another store; those of section 6.8, from 0.5, bind a store that serves the store protocol and a client that speaks it. A folder alone needs none of them: a folder may be versioned by any tool, git included. Section 8 applies to an application that keeps results or proposals in a model's folder, and to an implementation that reads them.

## 1. Objects

1. Every record, every kept file and every tree is an **object**, named by its hash: the SHA-256 of the UTF-8 bytes of its canonical form (Part III, section 6), as 64 lowercase hexadecimal digits.
2. A record's object is the record's canonical JSON. A kept file's object is its text as a canonical JSON string.
3. Two equal records anywhere, in any version, are one object. An object is never changed; a changed record is a new object.

Reference: `HashCache.record` and `buildTree` in `src/core/versions/tree.ts`; `sha256` in `src/core/versions/sha256.ts`.

## 2. Trees

A tree object is the canonical JSON of `{"tree": [[name, kind, hash], …]}`:

- `name` is one path segment;
- `kind` is `"t"` for a sub-tree and `"b"` for a leaf (a record or a kept file);
- the entries are sorted by `name`, comparing UTF-16 code units.

1. A model's tree has the folder's layout (Part III), with these differences: a record's leaf is named without `.json` (`architecture/level-0/wall/wall-south`), and `AGENTS.md` and hidden files are not in it. The project record is the leaf `project/project`, the levels `project/levels`, the order `project/order`; a view is `drawings/views/<kind>/<id>/view` with its chunks under `details/`. A kept file is a leaf at its own path, with its own name.
2. `eik.json` belongs in every stored version's tree, as the leaf `eik.json` whose object is its canonical JSON, so that a version says which format it is in.
3. A tree with more than 4096 entries is split into shard sub-trees named `~` followed by the first two hexadecimal digits, lowercase, of the SHA-256 of each entry's name. A shard holds the folder's entries whose names give it, and never a shard: shards are not nested. Shards are not part of any path: a reader of a tree MUST read through them, and MUST NOT treat a `~` name as a folder of the model.
4. The hash of a model's root tree identifies the model's state: two models with the same root hash hold the same records and kept files.

*Note (informative).* Rule 2 was decided on 11 October 2026. The reference implementation meets it since Stomra pull request #778 (live since 11 October 2026, `main` `8ebedf05`): every version it saves has the leaf `eik.json`, whose object is the canonical JSON of `{format, units}`, and it checks that leaf when it reads a version. A version saved before has none; it is read as `openeik/0.1-draft` in mm (Part I, 9.2, rule 5).

Reference: `buildTree`, `SHARD_LIMIT`, `listLeaves` and `readManifest` in `src/core/versions/tree.ts`. The reference reader reads a folder by building these objects from its files and reading them as a version (`manifestOfFolder` in `src/core/versions/eikFolder.ts`): a folder and a version are one format.

## 3. Versions and refs

1. A **version** is a commit object, the canonical JSON of `{"commit": {tree, parents, kind, at, author, name?, note?, summary, records}}`, and from 0.2 its `agents` (Part XVII, 4.3) and from 0.3 its `app` (section 3.5) where it gives them:
   - `tree`: the root tree's hash;
   - `parents`: the hashes of the versions it follows (none for the first, two for a merge);
   - `kind`: `start`, `auto`, `named`, `restore`, `merge` or `alternative`;
   - `at`: an ISO 8601 time; `author`: who made it;
   - `name`, `note`: for a named version;
   - `summary`: a summary of the changes (its form is implementation-defined in 0.1);
   - `records`: the number of records in the version: one for each record of a record list of the single-file form (Part III, 11), its elements, types, views and the rest, a view with its detail chunks counted once; the project record, the levels, `project/order.json`, `eik.json` and kept files are not counted, so that two stores that save one folder with one summary give it one id (rule 2).
2. A version's id is its object's hash. Versions are never rewritten: restoring an older state makes a new version on top.
3. A **ref** names the newest version of a line of work: `main`, and `alternatives/<slug>` for an alternative design. A ref MUST be moved only by compare-and-swap: the writer names the version it expects the ref to point at, and the move fails if it points elsewhere.
4. An automatic version of a model whose tree has not changed SHOULD NOT be made.

Reference: `Commit`, `VersionHistory.save` (the refs `main` and `alternatives/<slug>`, and the retry when a ref moved meanwhile) in `src/core/versions/history.ts`; `VersionBackend.setRef` in `src/core/versions/objects.ts`.

### 3.5 The application that wrote a version

*Part of 0.3. OpenEik 0.2 had it as the proposal `commitApp` (open questions, 125): a model of 0.2, read by 0.2's rules (Part I, 9.6, rule 3), is read by it only where a caller asks for it (decision D12).*

A version names the application that wrote it, beside the person who made it, its `author`, and the agents whose operations it holds (Part XVII, 4.3). A writer of a version of 0.3 writes it where its caller gives it; one of a version of 0.2 only where the proposal is asked for, without which a version's commit object of 0.2 is rule 1's; and a version of a model of 0.1 never names one.

1. **The member.** A version's commit object MAY carry `app`, `{name, version?}`: the application that wrote the model the version holds, `name` 1 to 100 characters and `version`, where given, 1 to 50, as an agent is named (Part XVII, 4.3), and no other member: `{"commit": {tree, parents, kind, at, author, app?, name?, note?, summary, records}}`. It names one application: of a model two applications' work went into, the one that wrote it as it is.
2. **What its writer says.** It is what the version's writer says, as `author` is: the application that wrote the model, which need not be the one that sends the version to a store, as a command-line tool pushes a version an authoring tool wrote. A reader and a host show it and verify nothing by it, and a host MUST NOT refuse a version because its `app` is not the client that sends it.
3. **In its id.** It is part of the commit object, and so of the version's id (rule 2): a version is never rewritten to add or to change it.
4. **Without it.** A version without `app` names no application, and a reader MUST NOT name one for it, from its `author`, its `note` or the client that sent it. No version written before the proposal names one.
5. **The other applications named.** A result manifest's `app`, `{name, version}` (section 8.2), and a proposal file's `by.app`, a text (section 8.7), keep their forms: this member is a commit object's alone.

Reference: the reference implementation does not write it yet; it asked for it (open questions, 125). In `@openeik/tools`: `commitApp`, and `pushVersion` and `push` with `app` on a folder of 0.3, and with `proposals: ["commitApp"]` too on one of 0.2, in `packages/openeik/src/store.js` and `packages/openeik/src/remote.js`; `openeik push --app <name>[@<version>] --proposal commitApp`.

*Note (informative).* The steward decided on 31 October 2026 that a version names the application that wrote it in 0.3 (open questions, 125): a migration proposal, which moves a line of work to a later version (Part I, 9.8), can then show which applications have written to the line, and so which of them do not write the later version yet. A host that keeps which of its clients sent each version keeps that apart from the version: it is the host's, and says who sent it, not who wrote it.

## 4. Diff

1. A diff between two versions compares their trees. Sub-trees with equal hashes on both sides are equal and SHOULD be skipped without being read.
2. Changes are reported by record: the list, the id, whether it was `added`, `removed`, `changed` or `moved`, and the top-level fields that differ (the revision left out). For a view, the counts of detail items added, removed and changed.
3. A record that moved to another folder (a wall to another level) is one changed record, found by its id, not a removal and an addition, with the path it left and the path it took. A record whose path alone changed, its object the same, is `moved`: one record, both its paths, no field. The change of layout of Part III, 4.4 moves records so, and so does a file renamed to the form of Part III, 2, rule 9.

*Note (informative).* Rule 3's `moved` was written on 30 October 2026 with the change of layout (Part III, 4.4; open question 85). Before it, a diff of `@openeik/tools` reported nothing for a record whose path alone changed, so that the paths such a change touches (Part XVI, 4, rule 1) were missed; a host that compares trees leaf by leaf, as EikHub does, found both paths all the same.

Reference: `treeDelta` and `diffTrees` in `src/core/versions/diff.ts`.

## 5. Merge

A merge joins two lines of work, *ours* and *theirs*, against the version both started from, the *base*.

1. Records are matched by id, list by list, never by path or by text.
2. For each record:
   - changed on one side only: that side's record is taken;
   - added on one side only: it is taken;
   - deleted on one side and unchanged on the other: it is deleted;
   - changed on both sides: it is merged member by member (rule 3);
   - changed on one side and deleted on the other: a conflict (`changed and deleted`);
   - added on both sides with different content: a conflict (`added twice`).
3. A member changed on one side only takes that side's value. Objects merge member by member, recursively. A list whose items are all objects with an `id` (a type's layers, a view's detail items, a sheet's viewports) merges item by item by id: our order, with their new items placed after the item that precedes them on their side. Any other value (a number, a point, a list without ids) changes as a whole. A member changed differently on both sides is a conflict (`both changed`), reported by its path.
4. A record merged from both sides gets the revision `max(ours, theirs) + 1`.
5. The project record and the project information merge as one record each; the levels merge as a list by id, and a conflict in them is settled for the whole list; kept files merge file by file. A kept file of one side at a path that the other side's records or kept files need, as a file or as a folder (Part III, 7.4), or whose path folds to one with a path of the other side's (Part III, 4.3, and 7, rule 8), is a conflict (`in the way`), reported with both sides' paths: the merged model could not be written as a folder otherwise. Of two kept files whose paths fold to one, the conflict is on the later in the order of their paths by UTF-16 code units, which a reader would leave alone.
6. A conflicted record keeps our side until a person chooses ours or theirs for it. A record settled by a choice, which both sides hold, keeps the chosen side's revision when that revision is the higher of the two, and otherwise gets `max(ours, theirs) + 1` (rule 4): either way, no earlier read of either side's record names the settled one, so a command based on it is refused (Part V, 3).
7. The merged model MUST pass the whole-model check (Parts I and II) before it is accepted. A merge that leaves a host missing or a type deleted under its elements MUST be refused, naming the records, never applied silently.

Reference: `mergeManifests`, `mergeObject`, `mergeKeyed` and `resolveMerge` in `src/core/versions/merge.ts`; the store's `restore` checks the merged model whole.

## 6. Remotes, push and pull

A model's versions may be kept in more than one store: an application's own store and a repository on a host, two hosts, or a folder and a host. This section says how two stores of one model exchange versions, as git's remotes do: work stays local until it is pushed, and what others pushed is pulled and merged.

Sections 6.1 to 6.7 say what a fetch, a push, a pull and a clone do, not how objects and refs travel between two stores: up to 0.4, OpenEik defines no protocol between stores ([Security and privacy, 1](https://openeik.org/spec/0.5/security-and-privacy#1)). The steward deferred such a protocol to a later version on 15 October 2026 (open questions, 28). 0.5 writes one, as the proposal `storeProtocol` of 0.4 did: section 6.8 is the protocol that `@openeik/tools` speaks, version 0, so that any store can serve it and any client speak it.

### 6.1 Remotes and tracking refs

1. A **remote** is another store that holds a repository of the same model. The local side gives it a name (`origin`).
2. A **remote-tracking ref** records, for one remote and one of its refs, the version last fetched from it or pushed to it: `{remote, ref, version, tree}`, where `tree` is that version's root tree. A tracking ref MUST record the version and the tree. An implementation MAY add members: when, by whom, the repository.
3. Tracking refs are kept apart from the local refs (section 3): they are never written to the shared repository, and no version's tree holds them. Where an implementation keeps them is its own choice, except in a folder.
4. A folder keeps its tracking refs in the hidden file `.eik/remotes.json`, `{"<remote>": {"url": …, "repo": …, "refs": {"<ref>": {"version": …, "tree": …}}}}`, which is not part of the model or of any version's tree (Part III, 1, rule 1). A reader of `.eik/remotes.json` MUST keep the members it does not know (Part I, 10).

### 6.2 Fetch

A **fetch** of a remote ref reads every object reachable from the remote ref's version that the local store lacks (versions, trees, records and kept files: section 1), and then sets the tracking ref to that version and its tree. A fetch that is part of a pull sets the tracking ref only once the pull's result is recorded (6.4), so that a pull that stops at a conflict leaves the tracking ref, and with it the next pull's base, where it was. A fetch moves no local ref.

### 6.3 Push

A **push** sends a local line of work to a ref of a remote.

1. **By compare-and-swap from the tracked version.** It moves the remote ref only by compare-and-swap (section 3, rule 3), from the version the tracking ref records (from none, for a ref the remote does not have yet). If the remote ref has moved since, nothing is written on the remote: the pusher pulls first (6.4), and pushes again.
2. **A published version is never rewritten.** The pushed version MUST descend from the tracked remote version: that version is in its history, through its parents. So the remote ref only moves forward, and no version the remote holds is rewritten or dropped. A squashed version (rule 3) has the tracked remote version as its first and only parent.
3. **Automatic versions stay local.** A version of kind `auto` MUST NOT be pushed to a shared ref. A tool MAY squash its local versions that are not on the remote into one version of kind `named`, with the push's message as its `name`, whose tree is the newest local tree and whose only parent is the tracked remote version: no other kind of version is needed. It MUST NOT squash a version that is on the remote already.
4. The pushed version's `summary` covers every change since the tracked remote version.
5. Only the objects the remote lacks are sent.
6. A push MUST NOT drop the members of records that the pusher does not know, nor kept files it did not change (Part I, 10; Part III, 7): the pushed tree holds them as the local one does.

### 6.4 Pull

1. A **pull** fetches the remote ref (6.2), then merges the remote version into the local version (section 5). The base is the version the tracking ref recorded before this pull: the remote version the local line last took in or sent out. Only where none is tracked is the base the newest version both lines have, found from their parents. The tracked version, not a version found from the parents, is the base because a line that squashed its pushes (6.3, rule 3) does not hold the version it pushed, and an ancestor found from the parents would count that push's changes twice. The pull checks the result whole (section 5, rule 7) and records a merge version whose parents are the local version and the remote version, in that order. Conflicts are settled as in any merge (section 5, rule 6).
2. When the local line holds the tracked remote version itself and has no version of its own after it, a pull MAY move the local ref to the remote version (a fast-forward) instead of recording a merge version. A line that squashed its pushes does not hold the remote version, so its pull records a merge version even when nothing local changed.
3. A folder that keeps no history of its own pulls by merging the remote version into its current files, with the tracked version as the base, writing the result as a writer does (Part III, 13), and then setting its tracking ref to the remote version. When its files still hold the tracked version's tree, it writes the remote version as it is (a fast-forward).
4. Kept files merge file by file (section 5, rule 5). A kept file that the remote line removed, and the local line did not change, is removed by the pull: the removal was made by the application that owns the file (Part III, 7.3), and keeping it would bring it back with the next push. Files a reader leaves alone (Part III, 7, rules 2 and 8) are never touched.

### 6.5 Clone

A **clone** fetches the refs asked for from a remote, `main` when none is named (6.2), sets each local ref to its version, and records a tracking ref for each ref it fetched and for no other (6.1). A clone into a folder fetches one ref, since a folder holds one version (Part III). A store or an application that keeps several refs MAY clone every ref of the remote.

Reference: `clone` in this repository's `packages/openeik/src/remote.js` clones one ref into a folder, `main` by default. Stomra 500 (live since 14 October 2026, `main` `cd7173c9`) clones `main`, a single-ref clone, into a new project connected to the repository as its remote.

### 6.6 Which versions are shared

Versions of kind `start`, `named`, `merge`, `restore` and `alternative` belong in a shared history. Versions of kind `auto` stay local (6.3, rule 3).

Reference: Stomra 495 (live since 14 October 2026, `main` `a7b7b13b`) pushes and pulls one remote ref, and keeps its tracking ref in the project's settings, with the repository, the version and the tree, and when and by whom it was set. It does not clone yet.


### 6.7 The formats a store reads

*Part of 0.4. OpenEik 0.3 had it as the proposal `storeFormats` (open questions, 128): what it asks is a store's, of every version it reads.*

A store says which versions of OpenEik it reads, and refuses a version it does not, so that a writer writes one the store can use. It defines no protocol between stores, which is deferred (open questions, 28): how a request asks for what it states, and how a refusal travels, is the store API's. From 0.5, section 6.8 says both: a store states `reads` in its answers to `GET <base>/v0` and to a repository's (6.8.4, rules 1 and 2), and refuses a move of a ref with 409 `format-unread` (6.8.5, rule 4).

1. **What it states.** A store that reads the models it holds, that draws, checks, reviews or merges them, states the formats it reads, `reads`, a list of `openeik/<major>.<minor>`, among what it tells of itself; and MAY state them among what it tells of each repository, which then repeats the store's or names fewer. A pre-release, `openeik/0.3-draft`, is read as its version, `openeik/0.3`.
2. **What it refuses.** It MUST refuse a pushed version whose format is not one of `reads` before it moves a ref (section 6.3, rule 1), with the code `format-unread`, naming the format it found, `version`, and `reads`. A version's format is its tree's `eik.json`'s (Part I, 9.2); a tree with none is read as `openeik/0.1-draft` (Part I, 9.2, rule 5).
3. **What a writer does.** A writer that writes more than one version MAY write the newest that it writes and the store reads. Since a store states `reads` of itself, a writer learns it before it makes a repository, and makes none the store cannot read.

Reference: none in the reference implementation. The host EikHub states `reads` of itself and of each repository, and refuses with `format-unread`, since 1 November 2026. In `@openeik/tools`: `storeReads`, `readsOfStore`, `newestShared`, `notThere` and a connected store's `storeInfo` in `packages/openeik/src/store.js` and `versions.js`; a refusal reaches its caller as the error `store-format-unread`, its `version` and `reads` with it.

### 6.8 The store protocol

*Part of 0.5. OpenEik 0.4 had it as the proposal `storeProtocol` (open questions, 28): what it asks is a store's and a client's, whatever version of OpenEik the store reads. It adds nothing to a model, and a validator checks nothing of it: its rules bind a store that serves the protocol and a client that speaks it.*

Sections 6.1 to 6.7 say what a fetch, a push, a pull and a clone do. This section says how they travel: the calls over HTTP by which a client reads and writes a repository's refs, objects, settings and assets' bytes in a store, version 0 of the protocol, `v0`. Any store can serve it and any client can speak it, so that a client that speaks it works with every store that serves it.

A **store** here is a version store that serves the protocol at a base URL, and keeps repositories, each the versions of one model (6.1, rule 1). A **client** is an implementation that makes its calls: a version store that fetches from, pushes to, pulls from or clones a remote, a reader of versions, or an application. Who may read and write a repository, how a person signs in, how a credential is issued, and how a repository is made and shared are each store's own (Security and privacy, 1, rule 3): the protocol carries a credential, and says what a store answers without one, and nothing more.

In what follows, `{repo}` stands for a repository's path, `<base>/v0/repos/{owner}/{name}`. The schemas of each call's body and answer, and of every refusal, are in [`schemas/0.5/storeProtocol/`](https://gitlab.com/openeik/spec/-/tree/main/schemas/0.5/storeProtocol), and `schemas/0.5/index.json`'s `rules` names them by call.

| Call | Body | Answer | Section |
|---|---|---|---|
| `GET <base>/v0` | | `{ok, api, reads?}` | 6.8.4 |
| `GET {repo}` | | `{ok, repo: {owner, name, visibility?, source?, reads?}, limits}` | 6.8.4 |
| `GET {repo}/refs` | | `{ok, refs: [{name, hash}]}` | 6.8.5 |
| `GET {repo}/refs/{name}` | | `{ok, hash}`, `null` where the ref names no version | 6.8.5 |
| `POST {repo}/refs/{name}` | `{hash, expected}` | `{ok, moved, current}`: a compare-and-swap | 6.8.5 |
| `POST {repo}/objects/has` | `{hashes}` | `{ok, present}` | 6.8.6 |
| `POST {repo}/objects/get` | `{hashes}` | `{ok, objects: {<hash>: <text>}}` | 6.8.6 |
| `POST {repo}/objects/put` | `{objects: {<hash>: <text>}}` | `{ok, stored}` | 6.8.6 |
| `POST {repo}/objects/{hash}/uploads` | `{}` | 201 `{ok, upload, partSize, most?}` | 6.8.7 |
| `PUT {repo}/objects/{hash}/uploads/{upload}/{n}` | part `n`'s bytes | `{ok, part, etag}` | 6.8.7 |
| `POST {repo}/objects/{hash}/uploads/{upload}` | `{parts: [{part, etag}]}` | `{ok, stored}` | 6.8.7 |
| `DELETE {repo}/objects/{hash}/uploads/{upload}` | | `{ok}` | 6.8.7 |
| `POST {repo}/log` | `{heads, limit}` | `{ok, objects: {<hash>: <text>}}` | 6.8.8 |
| `GET {repo}/meta/{key}` | | `{ok, value}` | 6.8.9 |
| `PUT {repo}/meta/{key}` | `{value}` | `{ok}` | 6.8.9 |
| `POST {repo}/assets/has` | `{hashes}` | `{ok, present, withheld}` | 6.8.10 |
| `PUT {repo}/assets/{sha256}` | the asset's bytes | 200 or 201 `{ok, stored}` | 6.8.10 |
| `GET {repo}/assets/{sha256}` | | the asset's bytes | 6.8.10 |

### 6.8.1 Calls and answers

1. **The base and the paths.** A store is reached at a base URL, `https`, or plain `http` to a loopback address only (6.8.3, rule 5), with no user information, query or fragment (6.8.3, rule 1). Each call's path is the base's path followed by the path the table gives: `<base>/v0` for the store, and `{repo}` and the paths under it for a repository. A client takes any `/` that ends a base away.
2. **Names in a path.** A repository is named `owner/name`, two names; a ref by its name (section 3, rule 3), each segment of the name a segment of the path; a setting by its key, one segment; an object by its hash, an asset by its SHA-256, and an upload by the id its store gave it. A client MUST percent-encode each segment ([RFC 3986](https://www.rfc-editor.org/rfc/rfc3986), 2.1), and MUST NOT make a call whose names have a segment that is empty, is `.` or `..`, or holds `/`, `\` or NUL: a URL resolves dot segments, so that such a name would reach another call, with the credential. A store MUST read a ref's name alike whether its `/` comes as a separator of segments or percent-encoded (`alternatives%2Fsouth-wing`).
3. **Bodies.** A call's body, where it has one, is a JSON object in UTF-8 ([RFC 8259](https://www.rfc-editor.org/rfc/rfc8259)), sent as `application/json`; but the bytes of a part of an object (6.8.7) and of an asset (6.8.10), which are sent as they are, as `application/octet-stream`.
4. **Answers.** A store answers every call with a JSON object in UTF-8, `application/json`, but a read of an asset's bytes that it answers with them: on success `{"ok": true, …}`, with the call's members and the status 200, or 201 where the table says so; on refusal `{"ok": false, "error": {"code", "message", "details"?}}`, with a status of 400 or more (6.8.2).
5. **What a client takes as an answer.** A client MUST take as a refusal an answer whose status is not one of 2xx, or whose body is not a JSON object with `ok` `true`. It MUST refuse an answer whose bytes are not UTF-8, and never read them with a replacement character in their place (Part III, 5, rule 1, and 12): the objects an answer carries are a model's files.
6. **Members not known.** A client MUST ignore an answer's members that it does not know, and a store a body's, so that a later version of the protocol can add members. Neither gives a member this section names another meaning.
7. **A store's own calls.** A store MAY answer calls of its own, under a prefix of its own: to make a repository, for people, sign-in, reviews and the like. It MUST NOT give a path this section names another meaning. A client MUST NOT need a call this section does not name to fetch, push, pull or clone; a later version of the protocol names its calls under a version of its own (`v1`).

### 6.8.2 Refusals

1. **Status and code.** A refusal's `code` names it, its `message` says it to a person, and its `details`, an object where the store gives them, say more. A store MUST answer each refusal the table names with the table's status, and SHOULD give the table's code; it MUST give `hash_mismatch` to an upload whose whole does not hash to its name (6.8.7, rule 4), and `asset-missing` and `format-unread`, with their `details`, to a move of a ref (6.8.5, rule 4), since a client acts on them. A client reads a refusal by its status, and by its code where this rule makes the code a MUST.

   | Status | Code | When |
   |---|---|---|
   | 400 | `bad_request` | a body that is not JSON, or a member missing or of another form; a log's `limit` out of range (6.8.8, rule 2) |
   | 400 | `bad_name` | a name that is no repository's, ref's or key's a store writes (6.8.5, rule 5) |
   | 400 | `bad_hash` | a hash that is not 64 lowercase hexadecimal digits |
   | 400 | `hash_mismatch` | an object whose text, or an upload whose bytes, do not hash to its name (6.8.6, rule 5; 6.8.7, rule 4) |
   | 400 | `utf8_invalid` | an object's text that is no well-formed Unicode, or an upload's bytes that are no UTF-8 |
   | 400 | `not_canonical` | an object's text that is not the canonical form of its value (6.8.6, rule 5) |
   | 400 | `nul` | an upload's text that holds U+0000, which no canonical form holds (6.8.7, rule 4) |
   | 400 | `commit` | a commit sent in parts (6.8.7, rule 4) |
   | 400 | `bad_part`, `bad_parts` | a part of no bytes, or numbered out of range; a completion's parts that are not every part, in order, as answered (6.8.7) |
   | 400 | `ref_reserved` | a move of a reserved ref (6.8.5, rule 5) |
   | 400 | `asset-hash` | an asset's bytes that do not hash to its SHA-256 (6.8.10, rule 2) |
   | 401 | `unauthorized` | no credential where one is needed, or one the store does not accept (6.8.3) |
   | 403 | `forbidden` | a credential that may read the repository and not do what it asks |
   | 404 | `not_found` | no such repository, or one the caller may not read (6.8.3, rule 4); no such call |
   | 404 | `upload_missing` | an upload that is not open (6.8.7) |
   | 404 | `asset-missing` | an asset whose bytes the store does not hold (6.8.10, rule 3) |
   | 405 | `method_not_allowed` | a path this section names, with another method |
   | 409 | `missing_object` | a move of a ref to a version the store does not hold (6.8.5, rule 4) |
   | 409 | `asset-missing` | a move of a ref to a version that names an asset whose bytes the store neither holds nor has withheld, `details.assets` each `{sha256, path, bytes}` (6.8.5, rule 4; Part XV, 5, rule 2) |
   | 409 | `format-unread` | a move of a ref to a version of a format the store does not read, `details` `{version, reads}` (6.8.5, rule 4; section 6.7, rule 2) |
   | 410 | `asset-withheld` | an asset the store has withheld (6.8.10; Part XV, 7) |
   | 413 | `too_large` | a call over a limit (6.8.11), a part larger than its upload's `partSize`, a whole larger than its upload's `most` |
   | 413 | `asset-too-large` | an asset larger than the store takes (6.8.10, rule 2) |
   | 429 | the store's | too many calls: a client MAY call again later |
   | 500, 503 | `internal`, `unavailable` | the store's own trouble |

2. **Their form.** The codes are written as the stores of version 0 write them, some with `_` and some with `-`: changing one would break a client that reads it. A later version of the protocol may give them one form.
3. **Codes of a store's own.** A store MAY answer a refusal the table does not name with a code of its own and a fitting status. A client MUST NOT read a refusal it does not know as a success, nor a code it does not know as one it knows.
4. **The message is text.** A `message` and the `details` are what the store says: a client shows them as text, and never evaluates them or shows them as markup (Security and privacy, 11).

### 6.8.3 Credentials

1. **A bearer token, in its header.** A client sends a credential as a bearer token in the `Authorization` header, `Authorization: Bearer <token>` ([RFC 6750](https://www.rfc-editor.org/rfc/rfc6750), 2.1), and in no other way: never in a URL, its user information, its query or its fragment, and never in a body. A URL is written into histories and logs, and travels in links. A store MUST NOT take a credential from a URL's query ([RFC 6750](https://www.rfc-editor.org/rfc/rfc6750), 2.3) or from a body.
2. **Without one.** A call without a credential is anonymous. A store MAY answer an anonymous call that reads a repository it lets anyone read, a public one; it answers its own `GET <base>/v0` to anyone (6.8.4, rule 1). It MUST refuse an anonymous call that writes, with 401, or with 404 where the repository is one the caller may not read (rule 4).
3. **One it does not accept.** A store MUST answer 401 to a call whose credential it does not accept, an `Authorization` header that is no bearer token among them, even where it would answer the call made anonymously: a caller that sends a credential means to be someone, and learns that the credential failed.
4. **What the caller may not read.** A store SHOULD answer a call about a repository that the caller may not read as it answers one that is not there, 404 `not_found`, so that its name does not show (Security and privacy, 9, rule 5); and a call that the caller may read the repository but not make, 403.
5. **Only over TLS.** A client MUST NOT send a credential other than over `https`, with the store's certificate validated, except to a loopback address of its own computer: `localhost`, 127.0.0.0/8 or `[::1]` (Security and privacy, 9, rule 2). It refuses such a base before it sends anything.
6. **Only to the store it is for.** A client MUST NOT send a credential to a store the person does not trust: to a base that it did not get from the person or record itself, or that changed since it last sent the credential there, without the person's confirmation (Security and privacy, 9, rule 1). A base that comes with a folder, in its `.eik/remotes.json` (6.1, rule 4), in a link (section 8.1.1, rule 3), or in a store's answer, is not one the person gave. A client SHOULD bind each credential to the origin it was issued for, its scheme, host and port, and MUST then send it to no other origin: it refuses a base of another origin before it sends anything.
7. **No redirect.** A store answers each call itself, never by a redirect (3xx). A client MUST NOT send a credential on to another origin when a call is redirected.
8. **What a credential may do** is the store's to say: who may read a repository, push to a ref or settle a review, and for how long. A store that keeps several repositories answers for each only to a caller who may read it, about its objects (Security and privacy, 9, rule 5) and its assets (Part XV, 5, rule 4).

### 6.8.4 The store and its repositories

1. **The store.** A store MUST answer `GET <base>/v0`, to anyone and without a credential, with what it tells of itself: `{ok: true, api: "v0", reads?}`, `api` the version of the protocol it serves and `reads`, where it states them, the formats it reads (section 6.7, rule 1). It MAY answer `GET <base>/` alike, and MAY add members of its own, a name for itself among them. A client reads `<base>/v0`, and reads a 404 there as a store that tells nothing of itself: a store written before this section may answer so.
2. **A repository.** `GET {repo}` answers `{ok: true, repo, limits}`. `repo` holds the repository's `owner` and `name`; its `visibility` where the store says, `public` where anyone may read it; its `source` (rule 3); and its `reads`, the formats the store reads for it, which repeat the store's or name fewer (section 6.7, rule 1). `limits` says what the store takes of the repository (6.8.11, rule 1). A repository that is not there, or that the caller may not read, is 404 (6.8.3, rule 4).
3. **A repository of an authoring application.** A store MAY say that a repository belongs to the project of an authoring application: its `source` is then an object whose `kind` names the application, and otherwise `null` or none. Its main line is that application's: a client SHOULD NOT push to its `main` unless it is that application or the person asks it to, and pushes an alternative instead (section 8.7, rule 5), which a person merges.

### 6.8.5 Refs

1. **Every ref.** `GET {repo}/refs` answers `{ok: true, refs}`: each ref of the repository that names a version, `{name, hash}`, in any order.
2. **One ref.** `GET {repo}/refs/{name}` answers `{ok: true, hash}`: the version the ref names, or `null` where it names none. A ref that names no version is no refusal.
3. **The compare-and-swap.** `POST {repo}/refs/{name}` with `{hash, expected}`, each a version's id or `null`, moves the ref, and answers `{ok: true, moved, current}`. A store MUST move the ref to `hash` only where it names `expected` when it moves it, `null` meaning no version, and nothing may move the ref between its comparison and its move (section 3, rule 3): it then answers `moved` `true` and `current` `hash`. Where the ref names another version, it MUST move nothing, and answers `moved` `false` and `current` the version the ref names, or `null`, with the status 200: the call was answered as asked. A `hash` of `null` removes the ref. A body without both members is refused (400 `bad_request`).
4. **What a ref moves to.** A store MUST refuse to move a ref to a version it does not hold (409 `missing_object`); to one that names an asset whose bytes it neither holds at the pointer's length nor has withheld (409 `asset-missing`, Part XV, 5, rule 2); and, where it states `reads`, to one whose format is not one of them (409 `format-unread`, section 6.7, rule 2). A client sends every object of a version, and every asset's bytes, that the store lacks before it moves a ref to it (6.3, rule 5; Part XV, 6, rule 1), so that a ref never names a version the store does not hold whole.
5. **The refs a store writes.** A store MUST take a move of `main` and of `alternatives/<slug>`, `<slug>` 1 to 80 of the letters `a` to `z`, digits and `-`, not starting with `-`; a client writes no other. The names under `proposals/`, `agent/`, `shares/` and `releases/` are reserved: a read of one answers `null`, and a move of one is refused (400 `ref_reserved`). A store refuses any other name it does not write (400 `bad_name`).
6. **A client's move.** A client moves a ref only from the version it read (6.3, rule 1). Where the answer is `moved` `false`, nothing moved: the client reads `current`, pulls (6.4) and pushes again, and MUST NOT move the ref from `current` without having merged what `current` holds.

For example, a push whose ref moved meanwhile (the hashes cut short here):

```text
POST /v0/repos/example-owner/terrace-house/refs/main
Authorization: Bearer …
Content-Type: application/json

{"expected":"4b7e…","hash":"9f2c…"}

200 {"ok":true,"moved":false,"current":"a1d0…"}
```

### 6.8.6 Objects

1. **Which it holds.** `POST {repo}/objects/has` with `{hashes}` answers `{ok: true, present}`: those of the hashes whose objects the store holds.
2. **Reading.** `POST {repo}/objects/get` with `{hashes}` answers `{ok: true, objects}`: each object the store holds of those asked for, `{<hash>: <text>}`, its text exactly as the store took it; those it lacks are left out.
3. **Checked as they enter a client.** A client MUST check each object an answer gives as it enters, as Security and privacy, 5.3, rule 1 says, whatever the store checked: that its text hashes to its name, and that it is the canonical form of the JSON it parses to (Part III, 6). It SHOULD refuse, before it parses it, a text longer than any file it reads takes as an object (Security and privacy, 7.2): for a file of 64 MiB, 6 × 64 MiB + 2 characters, the longest canonical JSON string of 64 MiB. It refuses a version that holds an object that fails, naming the object.
4. **Writing.** `POST {repo}/objects/put` with `{objects}`, `{<hash>: <text>}`, stores each object and answers `{ok: true, stored}`, the number of objects the call carried, each of which the store holds now. Storing an object the store holds already changes nothing.
5. **Checked as they enter a store.** A store MUST check each text of a put against its name, the SHA-256 of its UTF-8 bytes as 64 lowercase hexadecimal digits (section 1, rule 1): one that fails refuses the whole call, and no object of it is stored (400 `hash_mismatch`). It MUST refuse a text that is no well-formed Unicode, holding a lone surrogate, which has no UTF-8 (400 `utf8_invalid`). It SHOULD refuse a text that is not the canonical form of the JSON it parses to (400 `not_canonical`): a store that checks it holds only objects that Security and privacy, 5.3, rule 1 lets in, and one that does not holds what every client checks as it reads it (rule 3).
6. **A commit** is an object whose text starts with `{"commit":`. A store may read a commit's parents as it takes it, for the log (6.8.8), so a commit goes by `objects/put`, never in parts.

### 6.8.7 Large objects, in parts

A store MAY take an object larger than one put carries in parts, as an upload. It says so in a repository's `limits` (6.8.11, rule 1); a store that takes no uploads answers their calls 404.

1. **Opening an upload.** `POST {repo}/objects/{hash}/uploads` with `{}` opens an upload of the object `{hash}`, to a caller who may write the repository, and answers 201 `{ok: true, upload, partSize, most?}`: the upload's id, the size in bytes of each part but the last, and, where the store says, the most bytes the upload takes.
2. **A part.** `PUT {repo}/objects/{hash}/uploads/{upload}/{n}` with part `n`'s bytes answers `{ok: true, part, etag}`: `part` is `n`, and `etag` a text that names the bytes the store took. Parts are numbered from 1 to at most 10 000, each holds at least one byte and at most `partSize`, and a part sent again replaces it. A store refuses a part of no bytes or numbered out of range (400 `bad_part`), one larger than `partSize` (413 `too_large`), and one of an upload that is not open (404 `upload_missing`).
3. **What a client sends.** A client sends the object's UTF-8, each part the next slice of it, each but the last exactly `partSize` bytes. It MUST check that the upload's id is one segment of a path (6.8.1, rule 2) before it puts it into a path with its credential, and sends nothing more where it is not.
4. **Completing it.** `POST {repo}/objects/{hash}/uploads/{upload}` with `{parts}`, every part from 1 in order with the `etag` its answer gave, completes the upload. The store puts the parts together and checks the whole as it checks a put's text (6.8.6, rule 5): that it hashes to `{hash}` (400 `hash_mismatch`), that it is UTF-8 (400 `utf8_invalid`), that it holds no U+0000 (400 `nul`), that it is no commit (400 `commit`), and that it is at most `most` bytes (413 `too_large`); then it stores it and answers `{ok: true, stored: 1}`. A list that is not every part in order, as answered, is refused (400 `bad_parts`). A store that refuses the whole lets the upload go, and a client then opens another to try again.
5. **Aborting it.** `DELETE {repo}/objects/{hash}/uploads/{upload}` lets the upload and its parts go, and answers `{ok: true}`; an upload that is not open is 404 (`upload_missing`). A client aborts an upload that failed, whatever the abort answers. A store lets an upload that is never completed go, in its own time.
6. **What a client sends so.** A client sends an object in parts where its UTF-8 is larger than the repository's `putObjectBytes` and the store takes uploads (6.8.11, rule 1). It MUST NOT send a commit in parts, nor an object larger than `objectBytes` or an upload's `most`, nor one that would take more than 10 000 parts: it refuses such an object before it sends it. Reading needs none of this: `objects/get` gives a large object whole.

### 6.8.8 The log

1. **The history.** `POST {repo}/log` with `{heads, limit}` answers `{ok: true, objects}`: the commits reachable from `heads` through their `parents`, `{<hash>: <text>}`, at most `limit` of them. A store walks them breadth-first from the heads, each once, and writes them nearest first, so that a `limit` keeps the nearest. A head or a parent that the store does not hold, or that is no commit, is left out.
2. **Its bounds.** `limit` is a whole number from 0 to 20 000, and a store refuses another (400 `bad_request`); `heads` holds at most 1000 hashes (6.8.11, rule 2).
3. **What a client does.** A client checks each commit as an object (6.8.6, rule 3). A JSON object's members have no order ([RFC 8259](https://www.rfc-editor.org/rfc/rfc8259), 4), so a client that needs the commits' order SHOULD work it out from their parents; it reads a longer history by asking again from the parents of the oldest it has.

### 6.8.9 Settings

1. **A setting.** `GET {repo}/meta/{key}` answers `{ok: true, value}`: a small setting of the repository, any JSON value, and `null` where the key has none. `PUT {repo}/meta/{key}` with `{value}` sets it, `{value: null}` removes it, and it answers `{ok: true}`. Reading one needs the right to read the repository, and writing one the right to write it.
2. **Outside every version.** A setting is the repository's, and no version holds it: a store keeps no history of it, and a fetch, a push, a pull or a clone carries none. A key is one segment (6.8.1, rule 2); a client SHOULD keep to 1 to 200 of the letters `A` to `Z` and `a` to `z`, digits, `:`, `.`, `_` and `-`, which every store takes, and a store MAY refuse another (400 `bad_name`). A store MAY refuse a value larger than it keeps (413 `too_large`).

### 6.8.10 Assets

A store that keeps the bytes of assets beside its objects (Part XV, 5) answers three calls more; one that keeps none answers them 404.

1. **Which it holds.** `POST {repo}/assets/has` with `{hashes}`, SHA-256 digests, answers `{ok: true, present, withheld}`: those whose bytes the store holds for the repository, and those it has withheld (Part XV, 7). It answers for the repository alone, and MAY answer only a caller who may push to it (Part XV, 5, rule 4).
2. **Writing.** `PUT {repo}/assets/{sha256}` with the asset's bytes stores them, and answers `{ok: true, stored: true}`, 201 where the bytes are new and 200 where the store held them. A store MUST refuse bytes that do not hash to `{sha256}` (400 `asset-hash`), more bytes than it takes (413 `asset-too-large`), and a digest it has withheld (410 `asset-withheld`). It checks their length against the pointers that name them when a ref moves to a version (6.8.5, rule 4; Part XV, 5, rules 1 and 2).
3. **Reading.** `GET {repo}/assets/{sha256}` answers the bytes, to a caller who may read the repository, as `application/octet-stream`, with `Content-Disposition: attachment` and `X-Content-Type-Options: nosniff`, so that no browser shows them as a page. A store refuses with 404 `asset-missing` where it lacks them, and 410 `asset-withheld` where it has let them go (Part XV, 5, rule 3; 7); it never answers with other bytes.
4. **What a client does.** A client sends the bytes the store lacks before the objects and the ref (Part XV, 6, rule 1), and checks each asset it reads against the pointer that names it, its SHA-256 and its length, before it writes anything (Part XV, 5, rule 1; 6, rule 3).

### 6.8.11 Limits and batches

1. **What a repository takes.** A repository's `limits` is an object whose members, each a whole number of bytes greater than 0, say what the store takes of it; a store MAY leave any of them out:
   - `assetBytes`: the most bytes of one asset, at most 64 MiB (Part XV, 4). Where it is not given, a client takes 64 MiB.
   - `putObjectBytes`: the most UTF-8 bytes of one object's text that one `objects/put` carries. Where it is not given, 40 MiB.
   - `objectBytes`: the most UTF-8 bytes of an object, sent in parts where it is larger than `putObjectBytes`. A client takes it as no more than 6 × 64 MiB + 2, the longest object a file of 64 MiB makes (6.8.6, rule 3).
   - `uploadPart`: the size of an upload's parts.

   A store that gives `uploadPart`, or an `objectBytes` larger than `putObjectBytes`, takes objects in parts (6.8.7). A store that gives none of them takes objects of up to 40 MiB in one put, and none larger.
2. **What every store takes.** Every store MUST take calls up to these sizes, and a client makes none larger:

   | Call | At most |
   |---|---|
   | `objects/get` | 400 hashes |
   | `objects/has`, `assets/has` | 1000 hashes |
   | `objects/put` of several objects | a body of 4 MiB |
   | `objects/put` of one object | its text of `putObjectBytes`, its body as JSON writes it |
   | `log` | 1000 heads, and a `limit` of 20 000 |

   A store MAY take more. One that refuses a call over a size it takes answers 413 `too_large`.
3. **Batches.** A client asks about more hashes than a call takes in several calls, each of at most the limit. It puts objects in batches whose bodies stay under the limit, and an object whose body alone reaches it in a call of its own; `@openeik/tools` keeps each batch under 2 MiB, half the limit (`LIMITS`). The protocol has no pages: `refs` answers every ref, and a client reads a longer log by asking again (6.8.8, rule 3).

### 6.8.12 Fetch, push, pull and clone

1. **A fetch** (6.2) reads the remote ref (`GET {repo}/refs/{name}`), then its commit and its trees a level at a time by `objects/get`, through shards (section 2, rule 3), never asking for an object it holds already, and checks each as it enters (6.8.6, rule 3).
2. **A push** (6.3) reads the repository (`GET {repo}`: its limits and its `source`) and the remote ref, which MUST be the tracked version (6.3, rule 1); asks which of the version's objects the store holds (`objects/has`); sends the bytes of the assets the store lacks (`assets/has`, `PUT {repo}/assets/{sha256}`); puts the objects the store lacks, a large one in parts; puts the commit; and moves the ref by compare-and-swap from the tracked version (6.8.5, rules 3 and 6). Until the last call, nothing a reader sees has changed: objects and bytes name nothing until a ref names them.
3. **A pull** (6.4) is a fetch, and a merge of what it read, which is the client's: it makes no call more.
4. **A clone** (6.5) reads the refs it fetches (`GET {repo}/refs`, or `GET {repo}/refs/{name}` for each), and fetches each. A clone or a pull into a folder reads the bytes of every asset of the version it writes (`GET {repo}/assets/{sha256}`; Part XV, 6, rule 3).

### 6.8.13 Conformance

1. **A store** that claims the protocol answers each call of sections 6.8.4 to 6.8.10 as they say, and meets sections 6.8.1 to 6.8.3 and 6.8.11 in each answer; it may answer the calls of 6.8.7 and of 6.8.10 with 404 where it takes no uploads or keeps no assets' bytes.
2. **A client** that claims it makes only the calls this section names, as it says them, and meets 6.8.1, rules 2 and 5; 6.8.3, rules 1 and 5 to 7; 6.8.6, rule 3; 6.8.7, rules 3 and 6; and 6.8.11, rule 2.
3. **The runner.** [`tools/run-conformance-store-protocol.mjs`](https://gitlab.com/openeik/spec/-/blob/main/tools/run-conformance-store-protocol.mjs) drives a store's base URL through the protocol's calls, with a credential that may write a repository the store keeps, and checks each answer against the schemas and against the rules of this section, each check naming its rule and whether it is a MUST, a SHOULD or a MAY. It writes only objects of its own, refs under `alternatives/protocol-check-` and a setting of its own, and removes the refs and the setting when it is done. No class requires it while the protocol is proposed; a store MAY state that it passes it.

Reference: the reference implementation is a client: it keeps the versions of its shared projects in a store of this protocol (`src/versions/`). In `@openeik/tools`: `connectStore`, its calls, and `LIMITS`, `checkObject`, `notThere` and `readsOfStore` in `packages/openeik/src/store.js`; `sendAssets` and `fetchAssets` in `assets.js`; `clone`, `push`, `pull` and `fetchHead` in `remote.js`. The store of the package's tests, `packages/openeik/test/support/memory-api.mjs`, serves the protocol in memory.

*Note (informative).* Version 0 is the API that `@openeik/tools`' `connectStore` has spoken since October 2026, which three applications and one host speak: the steward deferred a protocol between stores on 15 October 2026 (open questions, 28), and it was written on 5 November 2026 from what that client does, so that a store can be written from the specification alone. What a host adds to it, its sign-in, its people, its reviews and its pages, is the host's: this section says only what every store answers and every client sends.

## 7. Git and other hosts (informative)

A folder is plain files, so it can be kept in git or any other version control system and in any object store, and pushed, pulled and reviewed there. Git's push and pull move git's commits, by git's rules; section 6 is the push and pull of OpenEik's own versions. A text merge of two stored-form files is often correct, because each member is one line, but it does not know records: it can join two edits that are each valid into an invalid model, and it cannot merge a moved record. An implementation SHOULD merge with the rules of section 5 and check the result whole. No git merge driver is specified in 0.1.

Forks that remember their origin are planned and not specified. A host's proposals (changes offered for review, as pull requests are) come from an envelope in 0.2 ([Part XVII, 6.3](https://openeik.org/spec/0.5/envelope)), and ownership by discipline folder is [Part XVI](https://openeik.org/spec/0.5/ownership)'s. Where no host offers proposals, an application offers its changes in a proposal file (section 8.7).

## 8. Applications' results and proposals

An application that works beside a model's author (a structural analysis, a daylight study, a quantity take-off, a supplier's tool) keeps its own work in the model's folder as kept files (Part III, 7): its own model of the building, the results it computes and the changes it proposes. It never writes them into the model's records. This section fixes where they go, the **result manifest**, which says what a set of results was computed from, and the **proposal file**, which offers changes to the records as commands. Kept with the model, they travel with it through every copy, version, restore and merge (sections 2 and 5).

### 8.1 The application's folder

An application keeps its files in a folder of its own at the top of the model's folder, with one **model folder** for each model of its own that it keeps there:

```text
<application>/<model>/                                  the model folder: one model of the application's
<application>/<model>/source.json                       what the model was built from (8.4)
<application>/<model>/…                                 the application's intent files: its model, settings, assumptions …
<application>/<model>/results/<run>/manifest.json       a result set's manifest (8.2)
<application>/<model>/results/<run>/…                   the result set's files
<application>/<model>/proposals/<id>.json               a proposal (8.7)
```

For example, an analysis whose prefix is `acme` keeps `acme/frame-a/model.json`, `acme/frame-a/source.json`, `acme/frame-a/results/r-5d1c0e9a7b32/manifest.json` with its results beside it, and `acme/frame-a/proposals/p-header-deeper.json`.

1. An application MUST keep its result sets and its proposals in this layout: each result set in a run folder `results/<run>/` of a model folder, with its manifest at `results/<run>/manifest.json`, and each proposal at `proposals/<id>.json` of a model folder. `<application>` is the application's folder, which Part I, 11.3 says to name by its prefix (`acme`); `<model>`, `<run>` and `<id>` are its own ids as path segments (Part III, 2). As kept files, these files MUST NOT take a record's path or a folder a record needs (Part III, 7.4): an application's folder is never a discipline folder or a record list's folder.
2. The **intent files** of a model folder are its kept files outside its `results/` and `proposals/` folders: what the application keeps of its own, `source.json` included. OpenEik does not define them, beyond `source.json` (8.4).
3. Every file of an application's folder is a kept file only if it is UTF-8 text of at most 1 MiB at a path a kept file may have (Part III, 7, rules 1 and 8); any other file is left alone and is not part of the model (Part III, 7.2). An application SHOULD write its JSON files in the stored form (Part III, 5), one item per file, so that a change is a small diff and a merge goes file by file (section 5, rule 5).
4. Results and intent files state their own units (Part III, 7.6).

### 8.1.1 Opening an application's folder

*Part of 0.5. OpenEik 0.4 had it as the proposal `appOpen` (open questions, 135): what it asks is a host's and an application's, of a building of any version.*

A host that shows a building's application folders can open one in its application, where the person gets a working copy of their own. It adds nothing to a model, and a validator checks nothing of it: its rules bind a host and an application. Where an application opens its folders is the registry's to say (Part I, 11.1): an entry of [`registry/extensions.json`](https://openeik.org/registry/extensions.json) MAY carry `open`, an `https` URL with no query and no fragment, the endpoint at which the application opens one of its folders. The registry is not versioned, so an entry may carry `open` before 0.5.

1. **What a host offers.** A host that shows a building's application folders (section 8.1) MAY offer to open each in its application, where the registry's entry of the folder's prefix (Part I, 11.3) has an `open` and is not withdrawn. It names the application by the entry's `registrant`. For a folder whose prefix has no `open`, or is withdrawn, it offers none.
2. **The query.** The host opens `open` with this query, each value percent-encoded as `application/x-www-form-urlencoded`:
   - `store`: the `https` base URL of the API of the store that holds the building, with no user information, query or fragment;
   - `building`: the building as that store names it, `owner/name`;
   - `version`: the id of the version whose folder it opens (section 3), 64 lowercase hexadecimal digits;
   - `model`: the name of the model folder under the prefix (section 8.1), `frame-a` for `acme/frame-a/`;
   - `run`: optional, the run id of one of the model folder's result sets (section 8.5), `r-` and 12 lowercase hexadecimal digits.

   No other parameter carries meaning.
3. **The application treats every parameter as untrusted input.** Anyone can write such a URL, so the application:
   - reads the version with the person's own credentials, and MUST NOT send a credential or a token to a store it does not already trust: for a store it does not know, it refuses, or asks the person;
   - SHOULD show the person the store and the building before it reads;
   - reads only: it opens a working copy that is the person's own, and writes into the building only when the person publishes, as it would otherwise. The building holds only what is published;
   - refuses with a message a `version` that the store does not hold, a `model` folder that the version does not hold, and a `run` that the model folder does not hold. It never guesses: it does not open the newest version, or another folder or run, in their place.

For example, a host opens the folder `acme/frame-a/` of a version, and its result set `r-2e13b39cbc7a`, where the registry's entry of `acme` has `"open": "https://acme.example/open"` (the store, the building and the version are illustrative):

```text
https://acme.example/open?store=https%3A%2F%2Fapi.store.example&building=example-owner%2Fterrace-house&version=4c8e0a1d3f5b7c9e2a4d6f8b0c1e3a5d7d1e9f3b2c4a6e8d0f1b3c5e7a9d2f4b&model=frame-a&run=r-2e13b39cbc7a
```

*Note (informative).* Security and privacy. The URL can be crafted by anyone, as a link in a message or on a page, and it names the store the application is to read from. Rule 3 is what keeps the person's token from being sent to a store the person did not choose: the application sends a credential only to a store it already trusts, as a version store sends one only to a remote it recorded itself ([Security and privacy, 9](https://openeik.org/spec/0.5/security-and-privacy#9), rule 1), and shows the person where it reads from. The URL carries no credential, and its parameters name no person: a store, a building as its store names it, a version, a folder and a run, and nothing of who opens it, so that the URL, kept in a browser's history or a server's log, carries no one's identity or token with it.

*Note (informative).* A working copy is the person's own until they publish it, as the steward decided on 4 November 2026 with the plan for sharing analyses through a host (open questions, 135): what they change in the application, and what the application saves while they work, stays out of the building, and a push or a proposal of the application's (section 6.3; section 8.7) is what publishes it, by the rules that bind it anyway.

Reference: none in the reference implementation. In `@openeik/tools`: `REGISTRY`, the registry as the package was built with it, `registration(prefix)` and `openUrl(entry, {store, building, version, model, run})`, which checks each value and gives the URL of rule 2 (`@openeik/tools/registry`).

### 8.2 The result manifest

A **result set** is the files of one run folder: its manifest and the results themselves, in a form the application chooses. The manifest is a JSON object (schema [`applications/result-manifest.schema.json`](https://openeik.org/schemas/0.1/applications/result-manifest.schema.json)):

| Member | Meaning |
|---|---|
| `format` | `"openeik-result/0.1"` |
| `kind` | what the results are, in the application's words: `structural-analysis`, `daylight`, `quantities` … |
| `app` | the application that made them: `{name, version}` |
| `computedFrom` | what they were computed from: `{version, versionKind, inputs, model, upstream}` (below) |
| `engine` | optional: what else decides the results, in the application's terms (a kernel, a code pack and its edition) |
| `made` | `{at, by}`: when they were made, as an ISO 8601 date and time with seconds and an offset (`2026-10-11T18:20:00Z`), and by whom: the id or email of the person who made them, not only a display name. A run that no person started, as an application or an agent makes one unattended, names that application or agent instead, by an id of its own |
| `summary` | optional: the few values a reviewer looks at first, in the application's terms |

The members of `computedFrom`:

| Member | Meaning |
|---|---|
| `version` | the version of the model that was read: a version's id (section 3; `versionKind` `"openeik"`), a git commit's id (`"git"`), or `null` for a folder that is under no version control. It is the version **before** the results were saved: the version that saves them is a child of it |
| `versionKind` | `"openeik"` or `"git"`; `null` exactly when `version` is `null` |
| `inputs` | `{count, digest}`: how many records the application read, and their digest (8.3) |
| `model` | the digest of the model folder's intent files (8.3). Its `source.json` is one of them (8.4, rule 1), so a writer always has a digest to write. `null` says that the folder had no intent files, and so no `source.json`: a reader reads it, and never calls those results current (8.4, rule 3) |
| `upstream` | `null` on a model's main line. On a fork or an alternative (a simplified model on a line of its own): `{repository, ref, version}`, where the line started: the repository (a URL or `owner/name`; `null` for the same repository), the ref it started from (`main`) and that ref's version when it did |

1. A writer MUST write `format` as `openeik-result/0.1`. A reader MUST read `openeik-result/0.1-proposal` as the same format: manifests written before 14 October 2026 carry that id. A manifest of any other `format` is not one this version defines, and a reader MUST NOT say whether its results are current.
2. `format`, `kind`, `app`, `made` and `computedFrom`, with all five of its members, are required. `engine` and `summary` are the application's; OpenEik does not define their members. A reader ignores members it does not know. An application's own data goes in `engine` and `summary`, and in the other objects of the manifest only as extension members (Part I, 11.2, rules 1 and 8).
3. A result set on a fork or an alternative names a version of that line in `computedFrom.version`, and the version of the line it started from in `upstream`. When the line is merged back, its result sets come along, and their `upstream` still says on which line they were computed.

Example (`engine`, `made` and `summary` as an analysis might give them; the hashes are illustrative):

```json
{
  "app": {"name": "an-analysis-app", "version": "0.5.0"},
  "computedFrom": {
    "inputs": {"count": 41, "digest": "3b0f6c2e9d41a8f07e2c5b19d6a4f0c8e7b3a2d1c9f8e7d6c5b4a3f2e1d0c9b8"},
    "model": "a41e0c7d5b3f2e1d9c8b7a6f5e4d3c2b1a0f9e8d7c6b5a4f3e2d1c0b9a8f7e6d",
    "upstream": null,
    "version": "7d1e9f3b2c4a6e8d0f1b3c5e7a9d2f4b6c8e0a1d3f5b7c9e2a4d6f8b0c1e3a5d",
    "versionKind": "openeik"
  },
  "engine": {"kernel": "an-analysis-app 0.5.0"},
  "format": "openeik-result/0.1",
  "kind": "structural-analysis",
  "made": {"at": "2026-10-11T18:20:00Z", "by": "jane@example.com"},
  "summary": {"maxUtilisation": 1.08}
}
```

### 8.2.1 A result set's reports

*Part of 0.5. OpenEik 0.4 had it as the proposal `reports` (open questions, 133): a model of 0.4, read by 0.4's rules (Part I, 9.6, rule 3), is read by it only where a caller asks for it (decision D12).*

A result manifest names the reports printed of its result set, so that a report is kept with the results it prints and the version they were computed from, and the asset that holds it is used.

1. **What a report is.** A report is a print of a result set, for people to read, such as a report PDF. It is not the results: they are the result set's own files (section 8.2), and nothing is read back from a report. A result manifest MAY carry `reports`, 1 to 20 entries `{asset, title?}`, each a report of its result set, kept as an asset ([Part XV](https://openeik.org/spec/0.5/assets)).
2. **Its asset.** `asset` is an asset's path, `assets/<sha256>.<ext>`, the form in which Part XIV names an unlinked drawing's `file.asset` (Part XV, section 8, rule 1), and the asset MUST be in the model (Part XV, section 8, rule 2; 8.1). A validator MUST report an `asset` that is no asset's path, such as a bare digest, as an error (`report-asset`), and one whose asset the model does not hold as an error (`report-missing`). An entry names no media type: the asset's is its extension's, by Part XV, section 4's table of kinds.
3. **Its title.** `title`, where it is given, is text of 1 to 200 characters that names the report for people, such as `Energy balance, issue A`. Nothing is decided by it.
4. **The format stays.** A manifest that carries `reports` is of the format `openeik-result/0.1`: a reader of a model of 0.4 that does not apply the proposal ignores the member, as rule 2 of section 8.2 has it, and a validator of one warns of a member it does not know (Part I, 10). Nor is the report a rendition to it: Part XIV, 15.2, rule 1 binds a rendition, and a PDF that a kept file names by its path is an application's asset, which Part XV, 8 governs. A version that holds a report is valid to a validator of 0.4 with or without the proposal.

For example, the manifest of section 8.2 with the report its application printed of the results:

```json
"reports": [
  {"asset": "assets/9c1f0e8d7b6a5c4d3e2f1a0b9c8d7e6f5a4b3c2d1e0f9a8b7c6d5e4f3a2b1c0d.pdf", "title": "Frame A, utilisation"}
]
```

*Note (informative).* A report belongs to its result set as its other files do. An application that removes a run folder (section 8.6) MAY remove an asset that only its manifest's `reports` named, which is then unused (Part XV, section 8, rule 3); the versions before keep it. A report is no rendition of a drawing (Part XIV, 15): no register names it, and none needs to.

Reference: none in the reference implementation. In `@openeik/tools`: the validator holds `reports` to `schemas/0.5/reports/reports.schema.json`, which the result manifest's schema of 0.5 names, counts each asset it names as used, and reports `report-asset` and `report-missing`; for a model of 0.5, and asked for with `proposals: ["reports"]` on a model of 0.4.

### 8.3 Digests

A **digest** names a set of files by their content, so that it is the same on a disk, in git and in any store:

1. Each file gives one **pair** `[path, hash]`: its leaf's path in a version's tree (section 2) and the hash of its object (section 1). For a record, that is its path without `.json` (`architecture/level-0/wall/wall-south`, `project/levels`) and the SHA-256 of its canonical JSON (Part III, 6); a view's pair is its `view.json`'s, without its detail chunks. For a kept file, it is its own path (`acme/frame-a/model.json`) and the SHA-256 of its text as a canonical JSON string.
2. The pairs are sorted by `path`, comparing UTF-16 code units, each path once.
3. The digest is the SHA-256, as 64 lowercase hexadecimal digits, of the canonical JSON of the sorted list: an array of two-string arrays.

- `computedFrom.inputs.digest` is the digest of the records the application read, and `inputs.count` the number of their pairs. `project/order.json` is never an input.
- `computedFrom.model` is the digest of the model folder's intent files (8.1, rule 2), `source.json` among them. A model folder without intent files, which a writer that meets 8.4, rule 1 never leaves, has `model` `null`, not the digest of an empty list.

For example, the south wall and the levels of `examples/one-storey-house` give the pairs `[["architecture/level-0/wall/wall-south","fe517b8853f582a78162d5e56ca5353b943c01b18caf6858099404d0c42b411c"],["project/levels","29da0824e3f9d2392427e4ffa02ccdd7a2f41bad6fb1bfdcb19d7ad35dfcd948"]]`, which is also their canonical JSON, and the digest `075c94e68d1ab7fbbde6248eebadffb2d558044cebbf39219c3915334e64a23a` (`count` 2).

Reference: `recordInputs`, `inputsDigest`, `intentInputs`, `runId` and `resultStatus` in this repository's `packages/openeik/src/result.js` compute the pairs, the digests, the run id (8.5) and the test of 8.4.

### 8.4 When results are current

1. **The selection.** Which records an application reads is its **selection**. An application that writes results MUST keep it in the model folder's `source.json`, a JSON object with at least:
   - `select`: `{categories?, lists?, ids?, paths?}`, each a list of strings: the elements whose `category` is in `categories`; every record of each list in `lists`, named as the single-file form names it (Part III, 11), with `project` for the project record and `levels` for the levels; the records whose `id` is in `ids`, in any list but the project, the levels and the order; and the records whose leaf path is in `paths`, a path naming its record in either layout of Part III, 4.4. A record that any of them names is selected.
   - `inputs`: the pairs (8.3) of the records the selection selected when the application last read the model: the list behind `computedFrom.inputs`.

   Its other members are the application's. `source.json` is an intent file, so a change to the selection, or a new reading of the model, changes `computedFrom.model`.
2. **Current or stale.** A result set is **current** in a version or a folder when both hold there:
   - the records its application's selection selects give `computedFrom.inputs.digest`;
   - the model folder's intent files give `computedFrom.model`.

   Otherwise it is **stale**. Comparing `computedFrom.version` with the newest version is not enough: the version that saves the results is a child of the one they were computed from, and later versions that change no input leave them current.
3. A reader that says whether a result set is current MUST decide it by rule 2, and rule 5. Without a `select` in `source.json` it cannot: it MUST NOT call the results current.
4. Where a result set is stale, comparing `source.json`'s `inputs` with the pairs of the records at those paths now says which inputs changed, were added or went. A pair is compared with the record its path names, by its list and id in either layout of Part III, 4.4 (its rule 9), so that a record that only moved is the same input.
5. **Records that only moved.** Where the digests differ, a result set is current all the same when the pairs of `source.json`'s `inputs` give `computedFrom.inputs.digest` and name, record by record (rule 4), exactly the records the selection selects now, each with the hash its pair gives: the records moved, as the change of layout moves them (Part III, 4.4, rule 8), and none changed. A reader MUST NOT call such a result set stale for that reason alone.

### 8.5 The run id

A run folder's name is its **run id**. It SHOULD be `r-` followed by the first 12 hexadecimal digits of the SHA-256 of the canonical JSON of `{"engine": …, "inputs": …, "model": …}`, whose members are the manifest's: its `engine` (left out when it has none), `computedFrom.inputs`, the object `{count, digest}` as it stands, and `computedFrom.model`, a digest or `null`. The manifest of the example in 8.2 gives

```json
{"engine":{"kernel":"an-analysis-app 0.5.0"},"inputs":{"count":41,"digest":"3b0f6c2e9d41a8f07e2c5b19d6a4f0c8e7b3a2d1c9f8e7d6c5b4a3f2e1d0c9b8"},"model":"a41e0c7d5b3f2e1d9c8b7a6f5e4d3c2b1a0f9e8d7c6b5a4f3e2d1c0b9a8f7e6d"}
```

and so the run id `r-2e13b39cbc7a`. The same inputs on the same engine give the same run id: a run made again goes to the same run folder. Where the application is deterministic, it gives the same results, and a manifest that differs from the first only in `made`, and in `computedFrom.version` where it read a later version that changed none of its inputs.

1. An application that makes a run again into a run folder that exists SHOULD leave the folder as it is when the run gives the same results and a manifest that differs only in `made` and `computedFrom.version`: the first manifest stays, with its `made` and its `version`, which still say truly when, by whom and from what the results were computed, and the version does not change. Where anything else differs, it replaces the folder's files, the manifest among them.

### 8.6 Old results

An application that writes results into a folder SHOULD keep there the latest result set of each model and every set that is named or signed, and remove the others: the history keeps them. Removing a run folder is an ordinary change.

### 8.7 The proposal file

Until a host offers proposals (section 7), an application offers changes to a model's records in a **proposal file**, `<application>/<model>/proposals/<id>.json`, never by writing the records itself. It is a JSON object (schema [`applications/proposal.schema.json`](https://openeik.org/schemas/0.1/applications/proposal.schema.json)):

| Member | Meaning |
|---|---|
| `format` | `"openeik-proposal/0.1"` |
| `intent` | what the change is for, in a sentence a person reads first |
| `base` | what it was made against: `{version, records}`. `version` names a version as `computedFrom.version` does (8.2), or is `null`; `records` gives, by id, each record that the commands change as it was there: `{hash, revision}`, its hash (Part III, 6) and its revision (Part I, 8) |
| `by` | `{app, person}`: the application that made it, with its version (`"an-analysis-app 0.5.0"`), and the person it was made for: an id or an email |
| `commands` | the change: one or more commands of Part V, in order |
| `dryRun` | optional: the last dry run of `commands` (Part V, 7.3), `{at, by, ok}`: when, by which command processor and version, and whether it passed; or `null` when none was made |
| `evidence` | optional: why, in the application's terms: a check, the values before and after, the result set that found it by its manifest's path |

1. A writer MUST write `format` as `openeik-proposal/0.1`. A reader MUST read `openeik-proposal/0.1-proposal` as the same format: proposals written before 14 October 2026 carry that id. An implementation MUST NOT apply a proposal whose `format` it does not implement.
2. `format`, `intent`, `base`, `by` and `commands` are required. A reader ignores members it does not know. An application's own data goes in `evidence`, and in the other objects of the proposal only as extension members (Part I, 11.2, rules 1 and 8).
3. `commands` is a batch (Part V, 7): applied in order, all or nothing, and checked as any batch is (Part V, 6). Each command that changes a record SHOULD carry its kind's precondition (`expectedRevision` …) matching `base`, so that a command made against a record that has changed since is refused rather than applied over the change.
4. **A person accepts a proposal.** Writing a proposal changes no record. The person, or a command processor or host acting on the person's word, runs `commands` as one batch on the line of work the person chooses, after a dry run if they like; or the person merges a line of work (an alternative, a branch) on which the commands were applied (section 5). A refused batch changes nothing, and the proposal stays as it was.
5. An application MUST NOT apply its own proposal to a line of work that a person edits, unless that person accepts it. It MAY apply it on a line of its own, made for the proposal, for the person to review and merge.
6. `dryRun` and `evidence` inform the person; they decide nothing. The batch run on acceptance decides.
7. A proposal file MUST NOT carry costs, prices or quotes: it is part of the model, and they are not (Part II, 12).

Example, a deeper beam proposed after an analysis (the hashes are illustrative):

```json
{
  "base": {
    "records": {
      "outdoor-header-0": {"hash": "a825935f50e8ecccaeb45f691fde75f186dea325a1cd8c1490399d48ae9174e3", "revision": 0}
    },
    "version": "7d1e9f3b2c4a6e8d0f1b3c5e7a9d2f4b6c8e0a1d3f5b7c9e2a4d6f8b0c1e3a5d"
  },
  "by": {"app": "an-analysis-app 0.5.0", "person": "jane@example.com"},
  "commands": [
    {"expectedRevision": 0, "id": "outdoor-header-0", "kind": "update", "patch": {"height": 270, "typeId": "type-beam-glulam-90x270"}}
  ],
  "dryRun": {"at": "2026-10-11T18:30:00Z", "by": "a command processor 1.0", "ok": true},
  "evidence": {"after": 0.81, "before": 1.08, "run": "acme/frame-a/results/r-5d1c0e9a7b32/manifest.json"},
  "format": "openeik-proposal/0.1",
  "intent": "Deeper header: bending utilisation 1.08"
}
```
