syntax = "proto3";

package apf.ai.v1;

import "google/protobuf/struct.proto";

option csharp_namespace = "Apf.Ai.Grpc.V1";

// Identity-bearing principal shipped with every request (carried in the JWT for
// internal callers, or in the request body for API-key callers — same shape).
message Principal {
  string subject = 1;
  repeated string roles = 2;
  map<string, string> attributes = 3;
}

// Default-deny ACL attached to every ingested chunk.
// At least one of allowed_roles or allowed_subjects must be non-empty,
// enforced at the controller, the DB CHECK constraint, and the post-filter.
message AclSpec {
  repeated string allowed_roles = 1;
  repeated string allowed_subjects = 2;
  repeated string denied_roles = 3;
  map<string, string> required_attributes = 4;
}

enum ChatRole {
  CHAT_ROLE_UNSPECIFIED = 0;
  CHAT_ROLE_SYSTEM = 1;
  CHAT_ROLE_USER = 2;
  CHAT_ROLE_ASSISTANT = 3;
  CHAT_ROLE_TOOL = 4;
}

message ChatMessage {
  ChatRole role = 1;
  string content = 2;
  string tool_call_id = 3;
  string name = 4;
}

// JSON-schema descriptor for caller-side tool execution. The AI service is
// tool-blind: it emits ToolCall events; the caller executes and posts back.
message ToolDescriptor {
  string name = 1;
  string description = 2;
  google.protobuf.Struct schema = 3;
}
