Files
piik/docs/adr/0017-contracts-fixed-before-release.md
T
AAA b406a086b9 docs: separate current contracts from investigation history
Condense collaboration procedures, protocol field inventories and repeated audit or experiment narration into their existing owners. Keep accepted decisions, unresolved work, primary sources and measurement limits. Detailed historical trials remain accessible at their measured Git revision without a second archive tree.

Align both language guides with the existing contribution value criteria. Keep local operating instructions out of public contributor guidance. Independent reviews preserved closed baseline choices and single-run evidence limits. Documentation and repository hygiene checks pass; this phase changes no runtime code.
2026-11-28 10:29:52 -05:00

8.4 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 product major defines protocol compatibility. Minor releases add features and patch releases fix them. A room writer can run on an older App or Browser, so either side of a request may lack a newer feature. Requiring exact versions or a permanent capability flag for every addition would constrain future releases.

The private 3.0 baseline has two relevant boundaries.

  • Domain and signed room replies identify their waiting operation separately from observer notifications. Unknown outcomes end that operation without confirming success. Wire objects accept ordinary extensions; typed store readers reject content they cannot preserve.
  • 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. A single product major/minor serves both Domain joins and local App discovery. The room writer may run on an older participant's device, so compatible additions must work with older readers and writers in either role. Versioning owns the rules for extensions and their mixed-version acceptance. Extensions must be exercised to stay usable (RFC 9170).
  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. Protocol Buffers offers evolution rules and breaking-change tooling. The compatibility rules also apply to JSON.
  • 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 same-major peers use the shared extension 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 writer's version determines which fields it can store. Preserving unrecognized fields would require a future extension with a concrete consumer.
  • Acceptance requires exercising the first public contract with mixed-version artifacts. TODO tracks that work.

References