syntax = "proto3";

package macp.v1;

// Canonical MACP envelope and generic acknowledgement/error shapes.

message Envelope {
  string macp_version = 1;
  string mode = 2;             // empty for Ambient Signals
  string message_type = 3;
  string message_id = 4;
  string session_id = 5;       // empty for ambient messages
  string sender = 6;
  int64 timestamp_unix_ms = 7; // informational only
  bytes payload = 8;
}

message MACPError {
  string code = 1;
  string message = 2;
  string session_id = 3;
  string message_id = 4;
  bytes details = 5;
}

enum SessionState {
  SESSION_STATE_UNSPECIFIED = 0;
  SESSION_STATE_OPEN = 1;
  SESSION_STATE_RESOLVED = 2;
  SESSION_STATE_EXPIRED = 3;
}

message Ack {
  bool ok = 1;
  bool duplicate = 2;
  string message_id = 3;
  string session_id = 4;
  int64 accepted_at_unix_ms = 5;
  SessionState session_state = 6;
  MACPError error = 7;
}
