Files
piik/docs/adr/0017-contracts-fixed-before-release.md
T
AAA a66dd25978 docs(protocol): apply extension rules at every wire object depth
Accept the corrected capacity decision and the version refusal from the review queue. Normal archive normalization refutes read-back equality; persistence keeps its own strict ingress while harmless wire fields are ignored uniformly. The NAT report fix is available on the independent research queue. Documentation and repository checks verify the updated owners.
2026-11-27 09:59:22 -05:00

13 KiB

ADR-0017: Contracts Fixed Before The First 3.0 Release

  • Status: proposed
  • Date: 2026-11-25, compatibility rule rewritten 2026-11-27

Context

3.0 is unpublished, so a private wire or storage shape is replaced without aliases, dual readers or migrations. After the first release, installed Apps and room stores hold the released shapes, and later versions have to work with them. Some contracts are costly to change after that; others can wait for a consumer. Versioning promises that an older App keeps working with a newer site within a major version, and that forward upgrades preserve durable authority.

The owner's direction for that promise: the first number of a version is the protocol, the second counts features and the third repairs; any two second numbers of one first number work together; and the way there is kept clean. Refusing what is not known and announcing a capability for each addition are not the way, because each leaves a check behind for every feature ever added. A room's writer makes this sharper than it is for a hosted service: it runs on a friend's App or Browser, so it is as often the oldest party in a room as the newest. The published 2.x line shows the cost of the other way: its server closes a connection over one field it does not know, its handshake requires one exact identifier, and its capability object has grown to fifteen entries, one per feature, which its promise to older peers keeps. The private 3.0 implementation currently has these boundaries:

  • Channel joins and local App discovery each require their current wire identifier (prototype/channel-core/src/lib.rs, src/client/channel/app-link.ts). Capture descriptions accept additions; selected capture results remain strict. Most Domain commands and the signed room commands and records are decoded closed: one field they do not know fails the whole of it (prototype/channel-core/src/wire.rs, conversation.rs).
  • A room's writer verifies who asks before it reads what is asked, so a command it cannot read is refused in that request's reply (prototype/channel-core/src/host.rs). A reader loses that with a record it cannot read: the request it answers is read first and then dropped with the failure (conversation.rs).
  • The Browser's pending request validates its terminal result (src/client/channel/session.ts). Unknown or mismatched outcomes reject that operation. The first published reader must retain this boundary when an extension is selected.
  • A room store opens only at one exact user_version (prototype/channel-core/src/storage.rs), and the Browser store aborts any upgrade (prototype/channel-browser/src/room-host.ts). This protects data; no format change has needed an upgrade yet.

Decision

Settled before the first public release

  1. Compatibility. Two parties work together when the first numbers of their versions are equal; when they differ, each tells its person which side to update. Four rules make any two second numbers work together. None of them is a flag for one feature or a path for one older peer.

    • A party states its two numbers once, where it is already described: a session when it joins, the Domain in its welcome or in the refusal that takes its place, the App in its discovery. The Domain publishes a session's numbers beside its key, so the numbers of a room's writer are those of its host's session. They decide what a client offers to its person. No result depends on them.
    • An unknown kind gets an answer where one is waited for. A request of a kind its receiver does not know is refused as unsupported in that request's reply. A reply of a kind its requester does not know ends that request as an unknown outcome and never as success. A notification of an unknown kind is ignored. A new action an older receiver must decline uses a distinct request. Changes to state older observers already display retain their baseline update semantics.
    • An unknown field is ignored by its final recipient at every depth. Relays forward enclosed signed payloads unchanged. Known bounds, types, required fields and kind values keep their defined contracts. A writer stores the fields it knows, and its confirmation carries the message as stored, so a sender sees what was kept. A new constraint whose omission would widen authority, lifetime, recipients or the target uses a distinct request; baseline requests retain all their defined constraints. A writer keeps nothing it cannot read, because deleting a message, clearing media and copying a room are promises about everything stored. What is written to last is the exception to ignoring, since nobody is there to be told: a store or an archive that holds what its reader does not know is refused before anything is installed.
    • A party gets a new form by asking for it. A request names the optional parts and forms it wants. One that names none gets what the first release gave. A part that was not asked for, or that the answering party does not know, is absent, and absent never means empty or deleted.

    What the four cannot express, which is changing or removing something that exists, waits for the next first number. That number also removes every branch written for an older peer, so such branches live for one first number at most. The first release exercises the rules at each independently implemented wire boundary, including a real mixed-version path. Tests cover unknown fields, requests, replies and notifications and a peer with a higher second number; shared decoders share boundary tests. An extension mechanism that is not used stops working (RFC 9170). Until the first release the one private number keeps its present job of telling apart builds that were not made for each other.

  2. Replies. A request ends in an explicit terminal outcome that tells rejected from unknown, and a copy sent to an observer is separate from the requester's reply. Idempotency is scoped by operation: chat already has durable nonces, and an invitation rotation is recovered by reading current state. History uses one signed, bounded page containing messages and their reaction snapshots. A released client that reads an unknown outcome as success cannot be corrected from the domain.

  3. Storage. The baseline covers Domain and room stores, portable archives, App settings, and Browser identity and read-position records. Retain inputs produced by the released writers. Compatible upgrades preserve authority, approved-origin scopes, data namespaces, identity credentials and valid configuration. Missing or malformed optional local preferences may use defaults; they never replace saved identity or restore authority. Add a concrete transactional upgrade only when a representation changes, and refuse a newer store before modification. No general migration framework is required. A store's layout number stays with its storage engine and says nothing about a peer.

  4. Restored history. A restore gives the room's history a new lineage that invalidates old read positions, and a normal restart keeps them. A position a released reader saved without a lineage cannot later be told apart from one that a restore made stale.

  5. History rules and durability. One owner holds the history rules that both writers execute. Authoritative IndexedDB writes use strict durability, because the architecture promises that history is committed before it is confirmed. Persistent storage guards against eviction and is requested at explicit hosting, not on every reconnect. A confirmed message that was lost cannot be recovered by a later version.

First public baseline

At the first public release, the owner selects the matched App, Web and Server revision. Its retained readers and writer-produced storage fixtures define the baseline protected by versioning.

Releases that share the first number keep what that baseline's parties rely on. Older Apps with newer Sites, newer Apps with older Sites, and older room writers with newer channels keep their established requests and replies with their meaning, and a new form reaches only a party that asked for it.

Deferred until a consumer needs it

  • Schema source. Defer a generation chain until a concrete consumer reduces overall ownership. Generated types must preserve required, omitted and null semantics and runtime validation, and replace their old owner.
  • State revision. Reopens when a delta or resume consumer needs it. Readers already accept an added top-level field.
  • Activity envelope. Dispatch over the owned kinds is exhaustive now. A generic envelope reopens when a concrete extension shows that it removes work without erasing the different authority and lifetime of each kind.
  • Bytes. Effect outputs become binary first: a 64 KiB watch delivery measured 66,773 bytes as binary and 240,441 bytes in outgoing JSON effects. The encoding of small wire keys reopens only if a measurement supports it.

Not Decided Here

  • The serialization format. All three clean-room designs chose Protocol Buffers for its evolution rules and breaking-change tooling. The decisions above hold for the present JSON as well, so the format can be weighed separately.
  • One SQLite schema in every runtime, using SQLite on the Browser's private file system in place of IndexedDB. It would make decision 5 structural. It needs a measurement of size and start-up cost first.
  • Moving the client engine into the core. It is internal and can change after a release.

Consequences

  • Any concrete incompatible wire or storage correction lands before release under the present rule for private experiments.
  • A feature added after release is a new kind, a new field or a new part to ask for, and raises the second number. No matrix of pairs is kept, because every pair that shares a first number works by the same four rules.
  • Refusing unknown fields goes from the wire. Stores and archives keep refusing what they do not know. One wire field per feature is not added again. The descriptions a join already carries of what a party's runtime can do stay: they describe a machine, not a version.
  • A room is as new as its writer for whatever is stored. A person can act on that sentence: the host updates. Keeping fields a writer cannot read, so that newer clients could use them through an older host, was weighed and left out: no feature in sight needs it, and it can be added later as one more addition under these rules.
  • Versioning states the rule for 3.0, whose direction the owner confirmed. The distance of the private code from it is release work.

References