syntax = "proto3"; package state.v1; import "google/protobuf/timestamp.proto"; // The instance audit feed: one org-scoped timeline over the settings trail, // access-policy changes and denials, identity lifecycle events, and runtime // events. The org and the reader's authority come from the authenticated // caller; no request names an org. service AuditService { // ListAudit returns one page of the caller's org feed, newest first. A // cursor reused with different filters is refused. rpc ListAudit(ListAuditRequest) returns (ListAuditResponse); // GetAuditHead returns a cheap token that changes when any trail grows. It // carries no rows and no org data; it is the live tail's signal. rpc GetAuditHead(GetAuditHeadRequest) returns (GetAuditHeadResponse); // CountAudit returns how many entries the filter matches, without a cursor // or a page bound. The export preflights it so an oversized download is // refused before any row is streamed. rpc CountAudit(CountAuditRequest) returns (CountAuditResponse); // RecordAuditExport appends the audit row of one completed export: its // format, the filter fingerprint and the row count, attributed to the // caller. The State Store writes it; the dashboard never does. rpc RecordAuditExport(RecordAuditExportRequest) returns (RecordAuditExportResponse); } // AuditFilter selects the entries a page returns. An empty list places no // restriction; categories, severities and outcomes are closed vocabularies // owned by internal/domain/audit. message AuditFilter { repeated string categories = 1; repeated string actions = 2; repeated string kinds = 3; string actor = 4; repeated string target_kinds = 5; repeated string target_ids = 6; repeated string severities = 7; repeated string outcomes = 8; // from is inclusive and to is exclusive, both in UTC. google.protobuf.Timestamp from = 9; google.protobuf.Timestamp to = 10; // q is a substring match over metadata only: record key, kind, actor, // source, field names, task/workflow/repo/stage. Never a value. string q = 11; } message ListAuditRequest { AuditFilter filter = 1; // cursor is opaque; a malformed one means newest. string cursor = 2; // limit is the page size. Zero means 100; the server caps it at 500. int32 limit = 3; } // AuditField is one changed field of a change set. old_value_json and // new_value_json are JSON values; an absent side is the JSON literal null. message AuditField { string field = 1; string old_value_json = 2; string new_value_json = 3; } // AuditEntry is one row of the feed: a grouped change set, a lifecycle event, // an aggregated denial, or a runtime event. Free-form values are redacted // before they reach this message. message AuditEntry { // id is stable across pages and live refreshes. string id = 1; string category = 2; google.protobuf.Timestamp at = 3; string actor = 4; string actor_kind = 5; string principal_id = 6; string target_kind = 7; string target_id = 8; string kind = 9; int64 record_version = 10; string request_id = 11; string source = 12; repeated AuditField fields = 13; string action = 14; string severity = 15; string outcome = 16; string detail = 17; string workspace_id = 18; int64 task_id = 19; // data_json is the redacted event data, empty when the row has none. string data_json = 20; } message ListAuditResponse { repeated AuditEntry entries = 1; string next_cursor = 2; bool has_more = 3; } message GetAuditHeadRequest {} message GetAuditHeadResponse { string token = 1; } message CountAuditRequest { AuditFilter filter = 1; } message CountAuditResponse { int64 count = 1; } message RecordAuditExportRequest { string format = 1; // filters_hash is the normalised filter's fingerprint, so an operator can // tell one exported view from another without storing the filter itself. string filters_hash = 2; int64 rows = 3; } message RecordAuditExportResponse {}