syntax = "proto3";
package globaladalliance.msrtb.v1;

option go_package = "github.com/msadsnetwork/gaa-standards-api/gen/msrtb";

// MS-RTB v1.0 Public Draft — normative Protobuf transport (proto3).
// JSON transport uses the equivalent JSON Schema under /downloads/schemas/.

message BidRequest {
  string request_id = 1;       // UUIDv7
  int64 timestamp_ms = 2;
  uint32 tmax_ms = 3;
  SupplyChainSignature auth = 4;
  InventoryContext inventory = 5;
  repeated AdSlot ad_slots = 6;
  PrivacyContext privacy = 7;
  AgentMetadata agent = 8;
  GreenMetrics green = 9;
}

message BidResponse {
  string request_id = 1;
  string dsp_node_id = 2;
  bytes dsp_signature = 3;     // Ed25519 over canonical request_id|dsp_node_id|bids_hash
  repeated Bid bids = 4;
  uint32 processing_time_us = 5;
}

message SupplyChainSignature {
  string seller_id = 1;
  string node_id = 2;
  bytes signature = 3;         // Ed25519 (see /standards/ms-trust)
  string schain_digest = 4;    // optional SHA-256 of schain JSON
}

message InventoryContext {
  Channel channel = 1;
  string domain_or_bundle = 2;
  repeated string contextual_tags = 3;
  string language = 4;         // BCP 47
  string country_iso = 5;      // ISO 3166-1 alpha-2
}

enum Channel {
  CHANNEL_UNSPECIFIED = 0;
  WEB = 1;
  MOBILE_APP = 2;
  CTV_OTT = 3;
  AI_CHAT_LLM = 4;
  GAMING_METAVERSE = 5;
}

message AdSlot {
  string slot_id = 1;
  uint32 width = 2;
  uint32 height = 3;
  double bid_floor_usd = 4;
  AdFormat format = 5;
}

enum AdFormat {
  FORMAT_UNSPECIFIED = 0;
  BANNER = 1;
  NATIVE = 2;
  VIDEO = 3;
  AUDIO = 4;
  SPONSORED_PROMPT = 5;
}

message PrivacyContext {
  bool cookieless_mode = 1;
  string gdpr_consent_hash = 2;
  string zk_cohort_token = 3;
}

message AgentMetadata {
  bool is_agentic_request = 1;
  string agent_protocol = 2;
  string intent_embedding_id = 3;
  bool allow_dynamic_creative = 4;
}

message GreenMetrics {
  uint32 hop_count = 1;
  double estimated_gco2e = 2;
}

message Bid {
  string bid_id = 1;
  string slot_id = 2;
  double price_usd = 3;
  string creative_payload = 4;
  string win_notice_url = 5;
  string advertiser_domain = 6;
}