Contract Versioning
Source of truth:
majestic-api-contractsREADME andsrc/version.ts
This document summarizes versioning for multi-client consumption.
Overview
Majestic uses SemVer for API contracts. The contract version is enforced via hash; schema changes require an explicit version bump. No silent drift.
Consumers: majestic-server, majestic-appletv, majestic-roku, majestic-tizen (and future clients).
Version Bump Rules
| Change | Bump | Impact |
|---|---|---|
| Field removed | Major | Breaking - all clients must update |
| Field renamed | Major | Breaking |
| Type changed incompatibly | Major | Breaking |
| Enum value removed | Major | Breaking |
| New optional field added | Minor | Additive - clients can ignore |
| New enum value added | Minor | Additive - forward-compat |
| Description/docs only | Patch | No wire change |
Multi-Client Implications
When you bump the contract version:
- Server - Must return responses that conform. Update implementation.
- Apple TV - Update models if shape changed. Sync with
majestic-api-contracts/swift/when applicable. - Roku - Update
CONTRACT_ALIGNMENT.mdand parsing. BrightScript has no types; doc parity matters. - Tizen - Same as Roku when implemented.
Header: Clients send X-Majestic-Client-Contract; server may enforce minimum version.
Hash Enforcement
majestic-api-contracts CI:
pnpm run generate→ canonical bundlepnpm run check:hash→ fails if schema changed without version bumpcontract-hashes.json→ SHA-256 perCONTRACT_VERSION
No exceptions. Schema change = version bump = hash update.
When Adding a New Field
- Add to schema (optional for minor, required for major).
- Bump
CONTRACT_VERSIONinsrc/version.ts. - Run
pnpm run generate. - Run
pnpm run check:hash- copy printed hash. - Add
"X.Y.Z": "sha256-..."tocontract-hashes.json. - Update server to return the field.
- Update clients when they need it (optional fields can be ignored).
Design Principle
Clients render. Servers decide. Contracts define.
Versioning protects the wire. It does not protect against clients that ignore new fields or fail to handle new enum values. Forward-compat rule: unknown values → treat as unknown or neutral; no crash.
Runtime Visibility
Server
- Startup: Logs contract version at boot.
- Request handling: When client sends
X-Majestic-Client-Contract, server compares major. Mismatch → 426 Upgrade Required withX-Majestic-Contractheader. - Response: All responses include
X-Majestic-Contractheader.
Client
- Request: Sends
X-Majestic-Client-Contract: X.Y.Zon all API requests. - 426 handling: Shows upgrade-required message.
- Version sync: Client contract version must match
majestic-api-contractsCONTRACT_VERSION.