Choose what this site may use

This site uses strictly necessary cookies to work and to remember your privacy choices. With your permission it would also load content hosted by other services, such as videos, maps and fonts, which then receive your network address and device data. We do not sell or share your personal information and we run no advertising. Choose Accept all, Reject all or Customise. You can change your mind at any time through Privacy choices at the foot of every page.

  • Always on

    Needed for the site to work and to remember your privacy choices. Always on.

  • Remembers settings you choose, such as the light or dark display, in your browser.

  • Loads videos, maps and other content hosted by other services. Those services receive your address and device data.

In this section: Build
Start
Reference code
Tools
API reference
Public services
Agents
Bindings and crosswalks

gRPC services

Source reference/rust/obsp-exchange/proto/obsp/v1/exchange.proto, schemas/proto/obsp/v1/common.proto

Services

ServiceCallRequestResponseFile
ExchangeGetObservationGetObservationRequestObservationItemreference/rust/obsp-exchange/proto/obsp/v1/exchange.proto
ExchangeListObservationsListObservationsRequeststream ObservationItemreference/rust/obsp-exchange/proto/obsp/v1/exchange.proto
ExchangeGetProductGetProductRequestProductItemreference/rust/obsp-exchange/proto/obsp/v1/exchange.proto
ExchangeListCorrectionNoticesListCorrectionNoticesRequeststream Documentreference/rust/obsp-exchange/proto/obsp/v1/exchange.proto
ExchangeSubscribeEventsSubscribeEventsRequeststream CloudEventreference/rust/obsp-exchange/proto/obsp/v1/exchange.proto

reference/rust/obsp-exchange/proto/obsp/v1/exchange.proto

syntax = "proto3";

package obsp.v1;

option go_package = "obsp/v1;obspv1";

import "google/protobuf/any.proto";
import "google/protobuf/timestamp.proto";
import "obsp/v1/common.proto";

// Exchange service of the gRPC binding: draft OIP-0024 (bindings/grpc in the proposal), not an accepted protocol
// contract. The Document message and the Exchange service with its request and response messages are taken from the
// draft's services.proto with their field numbers unchanged; the fields and messages marked "added" are not in the
// draft and are proposed by this reference implementation.
//
// JSON Schema stays authoritative for every protocol document: a document travels as a Document, its canonical JSON
// form with its digest, never re-modelled field by field. Every request opens with the RequestContext (specification
// section 4.3). Errors are gRPC statuses whose details carry an ErrorProblem (the draft mapping.yaml has the code
// table).

// A protocol document in its canonical JSON form (RFC 8785, UTF-8) and the OBSP digest of those bytes.
message Document {
  string schema = 1;          // protocol schema name, for example "observation-record"
  string schema_version = 2;  // the schemaVersion the document states
  bytes json = 3;
  Digest digest = 4;
}

// Exchange: consumers read observation records and products with their state.
service Exchange {
  // The latest version of one record (or the version named by "uni@version"). A withdrawn or recalled record is
  // returned only when include_history is set; then the earlier versions come in ObservationItem.history.
  rpc GetObservation(GetObservationRequest) returns (ObservationItem);
  // Records by system, observed property and phenomenon time. Without include_history: the latest version of each
  // record, withdrawn and recalled records left out. With include_history: every version, each with its own state
  // and, when superseded, its successor.
  rpc ListObservations(ListObservationsRequest) returns (stream ObservationItem);
  rpc GetProduct(GetProductRequest) returns (ProductItem);
  rpc ListCorrectionNotices(ListCorrectionNoticesRequest) returns (stream Document);
  // Added: the exchange's event log as CloudEvents, replayed after a cursor and then followed live, so a correction
  // reaches a subscriber at least once even across a reconnect.
  rpc SubscribeEvents(SubscribeEventsRequest) returns (stream CloudEvent);
}

message GetObservationRequest {
  RequestContext context = 1;
  string observation_uni = 2;  // a record UNI, or "uni@version" for one version
  bool include_history = 3;
}

message ListObservationsRequest {
  RequestContext context = 1;
  string system_uni = 2;
  string observed_property = 3;
  string phenomenon_from = 4;  // RFC 3339; records whose phenomenon time ends before it are left out
  string phenomenon_to = 5;    // RFC 3339; records whose phenomenon time starts after it are left out
  bool include_history = 6;
  uint32 page_size = 7;        // 0: the server default (100); at most 1000
  string page_token = 8;       // opaque; from next_page_token
}

message ObservationItem {
  Document record = 1;
  StateVector state = 2;       // correction_state: the version's correction state as served
  EvidenceRef provenance = 3;
  string next_page_token = 4;  // set on the last item of a page when more items follow
  // Added: the version that supersedes this one, as "uni@version"; empty unless the version is superseded.
  string superseded_by = 5;
  // Added: the version this one supersedes, as "uni@version"; empty for a first version.
  string supersedes = 6;
  // Added: this record version ("1" unless the publisher states another).
  string record_version = 7;
  // Added: whether this is the latest version of its record.
  bool latest = 8;
  // Added: the correction notices that changed this version's state, oldest first (their noticeUni).
  repeated string correction_notices = 9;
  // Added: GetObservation with include_history only: the earlier versions of the record, oldest first.
  repeated ObservationItem history = 10;
}

message GetProductRequest {
  RequestContext context = 1;
  string product_uni = 2;  // the productId, or "uni:product:<productId>"
  string version = 3;      // empty: the served version
  bool include_history = 4;
}

message ProductItem {
  Document manifest = 1;
  StateVector state = 2;
  EvidenceRef provenance = 3;
}

message ListCorrectionNoticesRequest {
  RequestContext context = 1;
  string record_uni = 2;    // empty: every notice
  string issued_after = 3;  // RFC 3339; empty: from the first notice
}

// Added.
message SubscribeEventsRequest {
  RequestContext context = 1;
  uint64 cursor = 2;              // the last sequence the subscriber has; 0 replays the whole log
  repeated string products = 3;   // product ids; empty: all
  repeated string types = 4;      // CloudEvents types; empty: all
}

// Added. A CloudEvent in the CloudEvents 1.0.2 Protobuf Event Format, carried in package obsp.v1 rather than
// io.cloudevents.v1 so that the binding stays one package; field names and numbers are those of the format.
// Extension attributes (obspsequence, obspcorrectionstate, obspsupersededby, ...) travel in attributes; the JSON
// data of an OBSP event travels as text_data (datacontenttype application/json).
message CloudEvent {
  string id = 1;
  string source = 2;  // URI-reference
  string spec_version = 3;
  string type = 4;
  map<string, CloudEventAttributeValue> attributes = 5;
  oneof data {
    bytes binary_data = 6;
    string text_data = 7;
    google.protobuf.Any proto_data = 8;
  }
}

message CloudEventAttributeValue {
  oneof attr {
    bool ce_boolean = 1;
    int32 ce_integer = 2;
    string ce_string = 3;
    bytes ce_bytes = 4;
    string ce_uri = 5;
    string ce_uri_ref = 6;
    google.protobuf.Timestamp ce_timestamp = 7;
  }
}

schemas/proto/obsp/v1/common.proto

syntax = "proto3";

package obsp.v1;

option go_package = "obsp/v1;obspv1";

import "google/protobuf/struct.proto";

// Foundation contract projection. JSON Schema remains authoritative for JSON
// documents. Implementation repository and version provenance is deployment metadata and
// is deliberately not repeated in RequestContext.

message Digest {
  string algorithm = 1;
  string hex = 2;
}

message EvidenceRef {
  string uri = 1;
  Digest digest = 2;
  string kind = 3;
  string recorded_at = 4;
}

message FieldViolation {
  string field = 1;
  string reason = 2;
  string code = 3;
}

message RequestContext {
  string schema_version = 1;
  string request_id = 2;
  string tenant_uni = 3;
  string workspace_uni = 4;
  string principal_uni = 5;
  string workload_uni = 6;
  string purpose = 7;
  repeated string jurisdiction_context = 8;
  string chronotope_uni = 9;
  string policy_digest = 10;
  string classification = 11;
  string data_cut_uni = 12;
  string correlation_id = 13;
  string idempotency_key = 14;
  reserved 15;
  google.protobuf.Struct extensions = 16;
}

message ErrorProblem {
  string schema_version = 1;
  string error_id = 2;
  string type = 3;
  string title = 4;
  int32 status = 5;
  string detail = 6;
  string instance = 7;
  string error_code = 8;
  string category = 9;
  string correlation_id = 10;
  string request_id = 11;
  bool retryable = 12;
  uint32 retry_after_seconds = 13;
  string policy_decision_ref = 14;
  EvidenceRef evidence_ref = 15;
  repeated FieldViolation violations = 16;
  google.protobuf.Struct extensions = 17;
}

message EventEnvelope {
  string schema_version = 1;
  string event_id = 2;
  string event_type = 3;
  string authority_owner = 4;
  string aggregate_uni = 5;
  uint64 aggregate_version = 6;
  string tenant_uni = 7;
  string workspace_uni = 8;
  string valid_at = 9;
  string recorded_at = 10;
  uint64 sequence = 11;
  string correlation_id = 12;
  string causation_id = 13;
  string correction_of = 14;
  bytes payload_json = 15;
  string payload_schema_ref = 16;
  string observation_time = 17;
  string publication_time = 18;
  string chronotope_uni = 19;
  string policy_digest = 20;
  string classification = 21;
  repeated string supersedes = 22;
  repeated EvidenceRef evidence_refs = 23;
  google.protobuf.Struct extensions = 24;
}

message StateVector {
  string implementation_state = 1;
  string service_state = 2;
  string verification_state = 3;
  string operational_state = 4;
  string release_state = 5;
  string claim_state = 6;
  string correction_state = 7;
}