Keel: Neutral Contracts for Racket Desktop Runtimes
| (require keel) | package: keel |
Keel defines a transport-neutral value codec, structured error shape, schema vocabulary, and lifecycle vocabulary. It deliberately does not define a renderer or protocol frame.
1 Values
procedure
(app-value? value) → boolean?
value : any/c
procedure
(encode-app-value value) → bytes?
value : app-value?
procedure
(decode-app-value encoded) → app-value?
encoded : bytes?
2 Structured errors
procedure
(app-error? value) → boolean?
value : any/c
procedure
(make-app-error code message [data]) → app-error?
code : app-error-code? message : string? data : app-value? = app-null
procedure
(app-error-code? value) → boolean?
value : any/c
procedure
(app-error-code error) → string?
error : app-error?
procedure
(app-error-message error) → string?
error : app-error?
procedure
(app-error-data error) → app-value?
error : app-error?
3 Schemas
A schema describes application messages without selecting their transport. Rivet can map a command to an RVT1 RPC while Glaze maps it to a GLZ1 invoke.
struct
(struct scalar-type (name))
name : symbol?
struct
element : schema-type?
struct
value : schema-type?
struct
(struct optional-type (element))
element : schema-type?
struct
(struct reference-type (name))
name : string?
value
value
value
value
value
value
value
value
value
struct
(struct schema-field (name type))
name : string? type : schema-type?
struct
(struct schema-record (name fields))
name : string? fields : (listof schema-field?)
struct
(struct schema-enum (name cases))
name : string? cases : (listof string?)
struct
(struct schema-parameter (name type))
name : string? type : schema-type?
struct
(struct schema-command (name parameters result error-codes))
name : string? parameters : (listof schema-parameter?) result : schema-type? error-codes : (listof app-error-code?)
struct
(struct schema-event (name type))
name : string? type : schema-type?
struct
(struct schema-state (name type))
name : string? type : schema-type?
procedure
(make-app-schema id revision [ #:records records #:enums enums #:commands commands #:events events #:states states]) → app-schema? id : string? revision : exact-nonnegative-integer? records : list? = null enums : list? = null commands : list? = null events : list? = null states : list? = null
procedure
(app-schema? value) → boolean?
value : any/c
procedure
(app-schema-id schema) → string?
schema : app-schema?
procedure
(app-schema-revision schema) → exact-nonnegative-integer?
schema : app-schema?
procedure
(app-schema-records schema) → (listof schema-record?)
schema : app-schema?
procedure
(app-schema-enums schema) → (listof schema-enum?)
schema : app-schema?
procedure
(app-schema-commands schema) → (listof schema-command?)
schema : app-schema?
procedure
(app-schema-events schema) → (listof schema-event?)
schema : app-schema?
procedure
(app-schema-states schema) → (listof schema-state?)
schema : app-schema?
procedure
(schema-type? value) → boolean?
value : any/c
procedure
(schema-name? value) → boolean?
value : any/c
procedure
(schema-type->app-value type) → app-value?
type : schema-type?
procedure
(app-schema->app-value schema) → app-value?
schema : app-schema?
procedure
(encode-app-schema schema) → bytes?
schema : app-schema?
The scalar descriptors are Null, Bool, Int64, Float64, String, Bytes, Value, Error, and Unit. Compound descriptors use list-type, map-type, optional-type, and reference-type. Definitions use schema-field, schema-record, schema-enum, schema-parameter, schema-command, schema-event, and schema-state.
4 Schema compatibility
Two schema revisions are comparable without a transport. A change is 'breaking when an existing peer can observe a different value, name, type, or closed case set, and 'compatible otherwise. Revision numbers are not interpreted: callers decide whether a revision replaces, supersedes, or accompanies the old one.
struct
(struct schema-change (severity path detail))
severity : (or/c 'breaking 'compatible) path : string? detail : string?
procedure
(app-schema-changes old new) → (listof schema-change?)
old : app-schema? new : app-schema?
procedure
(schema-compatible? old new) → boolean?
old : app-schema? new : app-schema?
5 Lifecycle
value
lifecycle-states : (listof symbol?)
value
procedure
(lifecycle-state? value) → boolean?
value : any/c
procedure
(lifecycle-terminal-state? value) → boolean?
value : any/c
procedure
(lifecycle-transition? from to) → boolean?
from : lifecycle-state? to : lifecycle-state?
value
request-terminal-outcomes : (listof symbol?)
procedure
(request-terminal-outcome? value) → boolean?
value : any/c
6 Further reading
The normative wire contract, including the tag table and the compatibility discipline, is docs/contract-v1.md in the repository. github.com/turlamai/keel hosts the source, the golden corpus, and the issue tracker; keel.jrtx.site is the contract homepage. Rivet and Glaze embed this contract behind their own transport envelopes.
7 Semantic versions
| (require keel/semver) | package: keel |
Strict SemVer 2.0 syntax and precedence. Build metadata is validated but ignored for ordering. Numeric prerelease identifiers contain only ASCII digits; all other identifiers compare lexically. Update channel policy and signed manifest formats remain outside this module.
procedure
(semver-compare left right) → (or/c -1 0 1)
left : string? right : string?
8 Shared update validation
| (require keel/update-contract) | package: keel |
Pure predicates for future common update manifests: update-version-range?, update-artifact-sha256?, update-artifact-size?, update-artifact-identity?, and unique-update-artifact-identities?. See the validation contract for argument shapes and legacy compatibility constraints. These predicates do not authenticate updates or change either consumer’s existing manifest format.
9 Normalized update model
| (require keel/update-manifest) | package: keel |
struct
(struct update-artifact ( platform architecture url sha256 size installer arguments component signature)) platform : string? architecture : string? url : string? sha256 : string? size : exact-positive-integer? installer : string? arguments : (listof string?) component : (or/c #f string?) signature : (or/c #f string?)
struct
(struct update-manifest ( application-id version build channel published-at minimum-version previous-version rollback-allowed? rollout artifacts)) application-id : string? version : string? build : exact-positive-integer? channel : string? published-at : string? minimum-version : string? previous-version : (or/c #f string?) rollback-allowed? : boolean? rollout : exact-integer? artifacts : (listof update-artifact?)
procedure
(update-artifact-identity artifact) → list?
artifact : update-artifact?
10 Canonical update payload
| (require keel/update-manifest-codec) | package: keel |
procedure
(encode-update-manifest manifest) → bytes?
manifest : update-manifest?
procedure
(decode-update-manifest payload) → update-manifest?
payload : bytes?
11 Update signature envelope
| (require keel/update-signature) | package: keel |
struct
(struct update-signature-envelope (key-id payload signature))
key-id : string? payload : bytes? signature : bytes?
procedure
(update-signature-input key-id payload) → bytes?
key-id : string? payload : bytes?
procedure
(encode-update-signature-envelope envelope) → bytes?
envelope : update-signature-envelope?
procedure
→ update-signature-envelope? raw : bytes?
procedure
(verify-update-signature-envelope envelope verifier) → update-manifest? envelope : update-signature-envelope? verifier : procedure?