chore(infra): add gRPC layer, update protobufs, remove immediate module

- Add gRPC service modules: auth, channel, channel settings, member,
  permission
- Update protobuf definitions and generated code
- Remove immediate/ real-time module (superseded by IM service)
- Update etcd discovery and registration
- Update cache, error, config, and build infrastructure
- Add ADR documentation
- Update OpenAPI spec
This commit is contained in:
zhenyi
2026-06-10 18:49:42 +08:00
parent 9eb77ab98b
commit 1000f8a80d
57 changed files with 22524 additions and 2703 deletions
+107
View File
@@ -154,6 +154,102 @@ message CompareCommitsResponse {
Oid merge_base = 4;
}
message FindCommitRequest {
RepositoryHeader repository = 1;
ObjectSelector revision = 2;
bool include_stats = 3;
}
message ListCommitsByOidRequest {
RepositoryHeader repository = 1;
repeated bytes oids = 2; // binary OID values
bool include_stats = 3;
}
message ListCommitsByOidResponse {
repeated Commit commits = 1;
}
message CommitIsAncestorRequest {
RepositoryHeader repository = 1;
string ancestor_oid = 2;
string descendant_oid = 3;
}
message CommitIsAncestorResponse {
bool is_ancestor = 1;
}
message CheckObjectsExistRequest {
RepositoryHeader repository = 1;
repeated string revisions = 2; // hex OIDs or rev expressions
}
message RevisionExistence {
string revision = 1;
bool exists = 2;
}
message CheckObjectsExistResponse {
repeated RevisionExistence revisions = 1;
}
message CommitsByMessageRequest {
RepositoryHeader repository = 1;
string query = 2; // regex or literal to search in commit messages
string revision = 3; // limit to this branch/ref (empty = all branches)
uint32 limit = 4;
uint32 offset = 5;
bool case_insensitive = 6;
}
message CommitsByMessageResponse {
repeated Commit commits = 1;
}
message GetCommitStatsRequest {
RepositoryHeader repository = 1;
ObjectSelector revision = 2;
}
message LastCommitForPathRequest {
RepositoryHeader repository = 1;
string path = 2;
string revision = 3; // limit history to this ref
bool literal_pathspec = 4;
}
message LastCommitForPathResponse {
Commit commit = 1;
string path = 2;
}
message CountCommitsRequest {
RepositoryHeader repository = 1;
string revision = 2;
string path = 3;
string since = 4; // ISO 8601 date
string until = 5;
}
message CountCommitsResponse {
uint64 count = 1;
}
message CountDivergingCommitsRequest {
RepositoryHeader repository = 1;
string left = 2;
string right = 3;
}
message CountDivergingCommitsResponse {
uint64 left_count = 1;
uint64 right_count = 2;
}
service CommitService {
rpc ListCommits(ListCommitsRequest) returns (ListCommitsResponse);
rpc GetCommit(GetCommitRequest) returns (Commit);
@@ -162,4 +258,15 @@ service CommitService {
rpc RevertCommit(RevertCommitRequest) returns (CreateCommitResponse);
rpc CherryPickCommit(CherryPickCommitRequest) returns (CreateCommitResponse);
rpc CompareCommits(CompareCommitsRequest) returns (CompareCommitsResponse);
rpc FindCommit(FindCommitRequest) returns (Commit);
rpc ListCommitsByOid(ListCommitsByOidRequest) returns (ListCommitsByOidResponse);
rpc CommitIsAncestor(CommitIsAncestorRequest) returns (CommitIsAncestorResponse);
rpc CheckObjectsExist(CheckObjectsExistRequest) returns (CheckObjectsExistResponse);
rpc CommitsByMessage(CommitsByMessageRequest) returns (CommitsByMessageResponse);
rpc GetCommitStats(GetCommitStatsRequest) returns (CommitStats);
rpc LastCommitForPath(LastCommitForPathRequest) returns (LastCommitForPathResponse);
rpc CountCommits(CountCommitsRequest) returns (CountCommitsResponse);
rpc CountDivergingCommits(CountDivergingCommitsRequest) returns (CountDivergingCommitsResponse);
}
+58
View File
@@ -132,9 +132,67 @@ message GetDiffStatsRequest {
DiffOptions options = 4;
}
message RawDiffRequest {
RepositoryHeader repository = 1;
string base = 2; // revision or OID
string head = 3;
DiffOptions options = 4;
}
message RawDiffResponse {
bytes data = 1;
}
message RawPatchRequest {
RepositoryHeader repository = 1;
string base = 2;
string head = 3;
}
message RawPatchResponse {
bytes data = 1;
}
message FindChangedPathsRequest {
RepositoryHeader repository = 1;
string base = 2;
string head = 3;
repeated string paths = 4; // filter to these paths
}
message ChangedPath {
enum Status {
CHANGED_PATH_STATUS_UNSPECIFIED = 0;
CHANGED_PATH_STATUS_ADDED = 1;
CHANGED_PATH_STATUS_MODIFIED = 2;
CHANGED_PATH_STATUS_DELETED = 3;
CHANGED_PATH_STATUS_RENAMED = 4;
CHANGED_PATH_STATUS_COPIED = 5;
CHANGED_PATH_STATUS_TYPE_CHANGED = 6;
}
Status status = 1;
string old_path = 2;
string new_path = 3;
uint32 additions = 4;
uint32 deletions = 5;
bool binary = 6;
}
message FindChangedPathsResponse {
repeated ChangedPath paths = 1;
}
service DiffService {
rpc GetDiff(GetDiffRequest) returns (GetDiffResponse);
rpc GetCommitDiff(GetCommitDiffRequest) returns (GetDiffResponse);
rpc GetPatch(GetPatchRequest) returns (stream GetPatchResponse);
rpc GetDiffStats(GetDiffStatsRequest) returns (DiffStats);
rpc RawDiff(RawDiffRequest) returns (stream RawDiffResponse);
rpc RawPatch(RawPatchRequest) returns (stream RawPatchResponse);
rpc FindChangedPaths(FindChangedPathsRequest) returns (FindChangedPathsResponse);
}
+61
View File
@@ -0,0 +1,61 @@
syntax = "proto3";
package gitks;
import "repository.proto";
// HookService provides gRPC callback hooks for git operations.
// External services can implement this interface to receive hook callbacks.
service HookService {
// Pre-receive hook callback: validate push before it happens.
rpc PreReceiveHook(PreReceiveHookRequest) returns (PreReceiveHookResponse);
// Update hook callback: validate each ref update individually.
rpc UpdateHook(UpdateHookRequest) returns (UpdateHookResponse);
// Post-receive hook callback: notify after push has completed.
rpc PostReceiveHook(PostReceiveHookRequest) returns (PostReceiveHookResponse);
}
message PreReceiveHookRequest {
RepositoryHeader repository = 1;
repeated RefUpdate ref_updates = 2;
string push_options = 3;
}
message PreReceiveHookResponse {
bool accept = 1;
string rejection_message = 2;
}
message UpdateHookRequest {
RepositoryHeader repository = 1;
string ref_name = 2;
string old_oid = 3;
string new_oid = 4;
}
message UpdateHookResponse {
bool accept = 1;
string rejection_message = 2;
}
message PostReceiveHookRequest {
RepositoryHeader repository = 1;
repeated RefUpdate ref_updates = 2;
}
message PostReceiveHookResponse {
repeated HookAction actions = 1;
}
message RefUpdate {
string old_oid = 1;
string new_oid = 2;
string ref_name = 3;
}
message HookAction {
string action_type = 1; // "trigger_ci", "update_index", etc.
string payload = 2;
}
+3
View File
@@ -10,6 +10,7 @@ message GitProtocolFeatures {
repeated string capabilities = 2;
repeated string server_options = 3;
repeated string agent = 4;
bool stateless = 5;
}
message ReferenceAdvertisement {
@@ -24,11 +25,13 @@ message AdvertiseRefsRequest {
RepositoryHeader repository = 1;
GitProtocolFeatures protocol = 2;
string service = 3;
bool raw = 4;
}
message AdvertiseRefsResponse {
repeated ReferenceAdvertisement references = 1;
repeated string capabilities = 2;
bytes raw_data = 3;
}
message UploadPackRequest {
+99
View File
@@ -0,0 +1,99 @@
syntax = "proto3";
package gitks;
import "google/protobuf/empty.proto";
import "oid.proto";
import "repository.proto";
message FindDefaultBranchNameRequest {
RepositoryHeader repository = 1;
}
message FindDefaultBranchNameResponse {
string name = 1;
}
message RefExistsRequest {
RepositoryHeader repository = 1;
string ref_name = 2;
}
message RefExistsResponse {
bool exists = 1;
}
message RefUpdateEntry {
string ref_name = 1;
string new_oid = 2;
string old_oid = 3; // expected old OID (empty = no check)
}
message UpdateReferencesRequest {
RepositoryHeader repository = 1;
repeated RefUpdateEntry updates = 2;
}
message UpdateReferencesResponse {
repeated string failed_refs = 1;
string error = 2;
}
message DeleteRefsRequest {
RepositoryHeader repository = 1;
repeated string ref_names = 2;
}
message DeleteRefsResponse {
repeated string failed_refs = 1;
string error = 2;
}
message FindRefsByOIDRequest {
RepositoryHeader repository = 1;
string oid = 2;
RefFilter filter = 3;
}
message RefFilter {
repeated string prefixes = 1; // e.g. ["refs/heads/", "refs/tags/"]
uint32 limit = 2;
}
message FoundRef {
string ref_name = 1;
string target_oid = 2;
bool symbolic = 3;
string symbolic_target = 4;
}
message FindRefsByOIDResponse {
repeated FoundRef refs = 1;
}
message ListRefsRequest {
RepositoryHeader repository = 1;
repeated string prefixes = 2;
string pattern = 3; // glob pattern, e.g. "refs/heads/*"
repeated string containing_oids = 4;
SortDirection sort_direction = 5;
Pagination pagination = 6;
}
message ListRefsResponse {
repeated FoundRef refs = 1;
PageInfo page_info = 2;
}
service RefService {
rpc FindDefaultBranchName(FindDefaultBranchNameRequest) returns (FindDefaultBranchNameResponse);
rpc RefExists(RefExistsRequest) returns (RefExistsResponse);
rpc UpdateReferences(UpdateReferencesRequest) returns (UpdateReferencesResponse);
rpc DeleteRefs(DeleteRefsRequest) returns (DeleteRefsResponse);
rpc FindRefsByOID(FindRefsByOIDRequest) returns (FindRefsByOIDResponse);
rpc ListRefs(ListRefsRequest) returns (ListRefsResponse);
}
+53
View File
@@ -0,0 +1,53 @@
syntax = "proto3";
package gitks;
import "oid.proto";
import "repository.proto";
message FindRemoteRepositoryRequest {
string remote_url = 1;
}
message RemoteHead {
string ref_name = 1;
string target_oid = 2;
bool symbolic = 3;
string symbolic_target = 4;
}
message FindRemoteRepositoryResponse {
repeated RemoteHead refs = 1;
bool exists = 2;
}
message FindRemoteRootRefRequest {
string remote_url = 1;
}
message FindRemoteRootRefResponse {
string ref_name = 1;
string target_oid = 2;
}
message UpdateRemoteMirrorRequest {
RepositoryHeader repository = 1;
string remote_url = 2;
string remote_name = 3; // defaults to "origin"
bool force = 4;
bool prune = 5;
repeated string refspecs = 6; // if empty, fetch all refs
}
message UpdateRemoteMirrorResponse {
bool ok = 1;
string error = 2;
}
service RemoteService {
rpc FindRemoteRepository(FindRemoteRepositoryRequest) returns (FindRemoteRepositoryResponse);
rpc FindRemoteRootRef(FindRemoteRootRefRequest) returns (FindRemoteRootRefResponse);
rpc UpdateRemoteMirror(UpdateRemoteMirrorRequest) returns (UpdateRemoteMirrorResponse);
}
+299
View File
@@ -139,6 +139,276 @@ message RepositoryMaintenanceResponse {
string stderr = 3;
}
message ListHooksRequest {
RepositoryHeader repository = 1;
}
message HookInfo {
string hook_type = 1;
string level = 2; // "server" or "custom"
string path = 3;
}
message ListHooksResponse {
repeated HookInfo hooks = 1;
}
message SetCustomHookRequest {
RepositoryHeader repository = 1;
string hook_name = 2; // "pre-receive", "update", "post-receive"
string content = 3; // Hook script content
}
message RemoveCustomHookRequest {
RepositoryHeader repository = 1;
string hook_name = 2;
}
enum SnapshotStorage {
SNAPSHOT_STORAGE_LOCAL = 0;
SNAPSHOT_STORAGE_S3 = 1;
SNAPSHOT_STORAGE_GCS = 2;
}
message SnapshotInfo {
string snapshot_id = 1;
string relative_path = 2;
uint64 size_bytes = 3;
string created_at = 4; // ISO 8601
string head_oid = 5;
}
message CreateSnapshotRequest {
RepositoryHeader repository = 1;
SnapshotStorage storage = 2;
string storage_path = 3;
}
message CreateSnapshotResponse {
string snapshot_id = 1;
uint64 size_bytes = 2;
string head_oid = 3;
}
message RestoreSnapshotRequest {
RepositoryHeader target_repository = 1;
string snapshot_id = 2;
SnapshotStorage storage = 3;
string storage_path = 4;
}
message ListSnapshotsRequest {
RepositoryHeader repository = 1;
uint32 limit = 2;
}
message ListSnapshotsResponse {
repeated SnapshotInfo snapshots = 1;
}
message DeleteSnapshotRequest {
string snapshot_id = 1;
SnapshotStorage storage = 2;
}
enum MoveRepositoryState {
MOVE_STATE_UNKNOWN = 0;
MOVE_STATE_PREPARING = 1;
MOVE_STATE_TRANSFERRING = 2;
MOVE_STATE_VERIFYING = 3;
MOVE_STATE_COMPLETED = 4;
MOVE_STATE_FAILED = 5;
MOVE_STATE_CANCELLED = 6;
}
message MoveRepositoryRequest {
RepositoryHeader source_repository = 1;
RepositoryHeader target_repository = 2;
}
message MoveRepositoryResponse {
MoveRepositoryState state = 1;
string error_message = 2;
}
message FetchRepositoryDataRequest {
RepositoryHeader repository = 1;
}
message FetchRepositoryDataResponse {
bytes data = 1;
bool done = 2;
}
message FindMergeBaseRequest {
RepositoryHeader repository = 1;
repeated bytes revisions = 2; // hex OIDs to find merge-base for
}
message FindMergeBaseResponse {
string base_oid = 1;
}
message WriteRefRequest {
RepositoryHeader repository = 1;
string ref_name = 2;
string new_oid = 3;
string old_oid = 4; // expected old OID (empty = no check)
bool force = 5;
}
message WriteRefResponse {
bool ok = 1;
string error = 2;
}
message SearchFilesByContentRequest {
RepositoryHeader repository = 1;
string query = 2; // regex pattern
string revision = 3; // tree-ish to search in (default HEAD)
uint32 max_results = 4; // default 100
bool case_sensitive = 5;
}
message SearchFilesByContentResponse {
repeated SearchResult results = 1;
}
message SearchFilesByNameRequest {
RepositoryHeader repository = 1;
string query = 2; // regex pattern for file names
string revision = 3;
uint32 max_results = 4;
bool recursive = 5;
}
message SearchFilesByNameResponse {
repeated SearchResult results = 1;
}
message SearchResult {
string path = 1;
uint32 line = 2; // 0 for name-only search
string matched_text = 3; // the surrounding line content
}
message ObjectsSizeRequest {
RepositoryHeader repository = 1;
repeated string oids = 2;
}
message ObjectsSizeResponse {
repeated ObjectSize sizes = 1;
}
message ObjectSize {
string oid = 1;
uint64 size = 2;
bool found = 3;
}
message RepositorySizeRequest {
RepositoryHeader repository = 1;
}
message RepositorySizeResponse {
uint64 size_bytes = 1;
}
message FindLicenseRequest {
RepositoryHeader repository = 1;
}
message FindLicenseResponse {
string license_spdx = 1; // SPDX identifier, e.g. "MIT"
string license_name = 2; // human-readable name
double confidence = 3; // 0.0 — 1.0
string license_path = 4; // path to LICENSE file
}
enum OptimizeStrategy {
OPTIMIZE_STRATEGY_UNSPECIFIED = 0;
OPTIMIZE_STRATEGY_HEURISTIC = 1; // auto-decide based on repo state
OPTIMIZE_STRATEGY_AGGRESSIVE = 2;
OPTIMIZE_STRATEGY_INCREMENTAL = 3;
}
message OptimizeRepositoryRequest {
RepositoryHeader repository = 1;
OptimizeStrategy strategy = 2;
}
message OptimizeRepositoryResponse {
bool ok = 1;
string stdout = 2;
string stderr = 3;
}
message GetRawChangesRequest {
RepositoryHeader repository = 1;
string base = 2; // revision or OID
string head = 3;
}
message RawChange {
enum Operation {
RAW_CHANGE_OPERATION_UNSPECIFIED = 0;
RAW_CHANGE_OPERATION_ADDED = 1;
RAW_CHANGE_OPERATION_MODIFIED = 2;
RAW_CHANGE_OPERATION_DELETED = 3;
RAW_CHANGE_OPERATION_RENAMED = 4;
RAW_CHANGE_OPERATION_COPIED = 5;
}
Operation operation = 1;
string old_path = 2;
string new_path = 3;
uint32 old_mode = 4;
uint32 new_mode = 5;
string old_oid = 6;
string new_oid = 7;
double similarity = 8;
}
message GetRawChangesResponse {
repeated RawChange changes = 1;
}
message FetchRemoteRequest {
RepositoryHeader repository = 1;
string remote_url = 2;
string remote_name = 3; // defaults to "origin"
repeated string refspecs = 4;
bool force = 5;
bool prune = 6;
}
message FetchRemoteResponse {
bool ok = 1;
string error = 2;
}
message CreateRepositoryFromURLRequest {
RepositoryHeader repository = 1;
string remote_url = 2;
bool mirror = 3;
}
message CreateRepositoryFromURLResponse {
Repository repository = 1;
}
service RepositoryService {
rpc GetRepository(GetRepositoryRequest) returns (Repository);
rpc InitRepository(InitRepositoryRequest) returns (Repository);
@@ -154,4 +424,33 @@ service RepositoryService {
rpc GarbageCollect(GarbageCollectRequest) returns (RepositoryMaintenanceResponse);
rpc Repack(RepackRequest) returns (RepositoryMaintenanceResponse);
rpc WriteCommitGraph(WriteCommitGraphRequest) returns (RepositoryMaintenanceResponse);
// Hooks management
rpc ListHooks(ListHooksRequest) returns (ListHooksResponse);
rpc SetCustomHook(SetCustomHookRequest) returns (google.protobuf.Empty);
rpc RemoveCustomHook(RemoveCustomHookRequest) returns (google.protobuf.Empty);
// Snapshot operations
rpc CreateSnapshot(CreateSnapshotRequest) returns (CreateSnapshotResponse);
rpc RestoreSnapshot(RestoreSnapshotRequest) returns (google.protobuf.Empty);
rpc ListSnapshots(ListSnapshotsRequest) returns (ListSnapshotsResponse);
rpc DeleteSnapshot(DeleteSnapshotRequest) returns (google.protobuf.Empty);
// Repository move
rpc MoveRepository(MoveRepositoryRequest) returns (MoveRepositoryResponse);
rpc FetchRepositoryData(FetchRepositoryDataRequest) returns (stream FetchRepositoryDataResponse);
rpc FindMergeBase(FindMergeBaseRequest) returns (FindMergeBaseResponse);
rpc WriteRef(WriteRefRequest) returns (WriteRefResponse);
rpc SearchFilesByContent(SearchFilesByContentRequest) returns (SearchFilesByContentResponse);
rpc SearchFilesByName(SearchFilesByNameRequest) returns (SearchFilesByNameResponse);
rpc ObjectsSize(ObjectsSizeRequest) returns (ObjectsSizeResponse);
rpc RepositorySize(RepositorySizeRequest) returns (RepositorySizeResponse);
rpc FetchRemote(FetchRemoteRequest) returns (FetchRemoteResponse);
rpc CreateRepositoryFromURL(CreateRepositoryFromURLRequest) returns (CreateRepositoryFromURLResponse);
rpc FindLicense(FindLicenseRequest) returns (FindLicenseResponse);
rpc OptimizeRepository(OptimizeRepositoryRequest) returns (OptimizeRepositoryResponse);
rpc GetRawChanges(GetRawChangesRequest) returns (GetRawChangesResponse);
}
+26
View File
@@ -0,0 +1,26 @@
syntax = "proto3";
package appks.im.v1;
// Internal service-to-service authentication.
// appks issues API keys (stored in Redis), remote services
// carry the key in gRPC metadata "x-api-key", and call
// Authenticate to verify identity.
message AuthenticateRequest {
string api_key = 1;
}
message AuthenticateResponse {
bool authenticated = 1;
string service_name = 2;
string service_id = 3;
repeated string scopes = 4;
int64 expires_at = 5;
}
service InternalAuthService {
// Verify an API key and return the associated service identity.
// Called by remote services to authenticate themselves.
rpc Authenticate(AuthenticateRequest) returns (AuthenticateResponse);
}
+212
View File
@@ -0,0 +1,212 @@
syntax = "proto3";
package appks.im.v1;
import "google/protobuf/timestamp.proto";
// Channel management service for the IM microservice.
// Provides CRUD for channels and categories, plus channel statistics.
// ── Enums ──────────────────────────────────────────────────────────────
enum ChannelType {
CHANNEL_TYPE_UNSPECIFIED = 0;
CHANNEL_TYPE_PUBLIC = 1;
CHANNEL_TYPE_PRIVATE = 2;
CHANNEL_TYPE_DIRECT = 3;
CHANNEL_TYPE_GROUP = 4;
CHANNEL_TYPE_REPO = 5;
CHANNEL_TYPE_SYSTEM = 6;
}
enum ChannelKind {
CHANNEL_KIND_UNSPECIFIED = 0;
CHANNEL_KIND_TEXT = 1;
CHANNEL_KIND_VOICE = 2;
CHANNEL_KIND_STAGE = 3;
CHANNEL_KIND_FORUM = 4;
CHANNEL_KIND_ANNOUNCEMENT = 5;
}
enum Visibility {
VISIBILITY_UNSPECIFIED = 0;
VISIBILITY_PUBLIC = 1;
VISIBILITY_PRIVATE = 2;
VISIBILITY_INTERNAL = 3;
VISIBILITY_WORKSPACE = 4;
VISIBILITY_PROTECTED = 5;
VISIBILITY_HIDDEN = 6;
VISIBILITY_SECRET = 7;
}
// ── Messages ───────────────────────────────────────────────────────────
message Channel {
string id = 1;
string workspace_id = 2;
optional string category_id = 3;
optional string parent_channel_id = 4;
string name = 5;
optional string topic = 6;
optional string description = 7;
ChannelType channel_type = 8;
ChannelKind channel_kind = 9;
Visibility visibility = 10;
int32 position = 11;
bool nsfw = 12;
bool read_only = 13;
bool archived = 14;
optional string created_by = 15;
optional int32 rate_limit_per_user = 16;
optional google.protobuf.Timestamp archived_at = 17;
optional string last_message_id = 18;
optional google.protobuf.Timestamp last_message_at = 19;
google.protobuf.Timestamp created_at = 20;
google.protobuf.Timestamp updated_at = 21;
}
message ChannelStats {
string channel_id = 1;
int32 members_count = 2;
int32 messages_count = 3;
int32 threads_count = 4;
int32 reactions_count = 5;
int32 mentions_count = 6;
int32 files_count = 7;
optional google.protobuf.Timestamp last_activity_at = 8;
google.protobuf.Timestamp updated_at = 9;
}
message ChannelCategory {
string id = 1;
string workspace_id = 2;
string name = 3;
int32 position = 4;
bool collapsed = 5;
google.protobuf.Timestamp created_at = 6;
google.protobuf.Timestamp updated_at = 7;
}
// ── Requests / Responses ──────────────────────────────────────────────
message GetChannelRequest {
string channel_id = 1;
}
message GetChannelResponse {
Channel channel = 1;
}
message ListChannelsRequest {
string workspace_name = 1;
optional string category_id = 2;
optional ChannelType channel_type = 3;
optional ChannelKind channel_kind = 4;
int32 limit = 5;
int32 offset = 6;
}
message ListChannelsResponse {
repeated Channel channels = 1;
int32 total = 2;
}
message CreateChannelRequest {
string workspace_name = 1;
string name = 2;
optional string topic = 3;
optional string description = 4;
optional string channel_type = 5;
optional string channel_kind = 6;
optional string visibility = 7;
optional string category_id = 8;
optional string parent_channel_id = 9;
optional string created_by = 10;
optional int32 rate_limit_per_user = 11;
}
message CreateChannelResponse {
Channel channel = 1;
}
message UpdateChannelRequest {
string channel_id = 1;
optional string name = 2;
optional string topic = 3;
optional string description = 4;
optional string visibility = 5;
optional int32 position = 6;
optional bool nsfw = 7;
optional bool read_only = 8;
optional bool archived = 9;
optional string category_id = 10;
optional int32 rate_limit_per_user = 11;
}
message UpdateChannelResponse {
Channel channel = 1;
}
message DeleteChannelRequest {
string channel_id = 1;
}
message DeleteChannelResponse {}
message GetChannelStatsRequest {
string channel_id = 1;
}
message GetChannelStatsResponse {
ChannelStats stats = 1;
}
message ListCategoriesRequest {
string workspace_name = 1;
}
message ListCategoriesResponse {
repeated ChannelCategory categories = 1;
}
message CreateCategoryRequest {
string workspace_name = 1;
string name = 2;
optional int32 position = 3;
}
message CreateCategoryResponse {
ChannelCategory category = 1;
}
message UpdateCategoryRequest {
string category_id = 1;
optional string name = 2;
optional int32 position = 3;
optional bool collapsed = 4;
}
message UpdateCategoryResponse {
ChannelCategory category = 1;
}
message DeleteCategoryRequest {
string category_id = 1;
}
message DeleteCategoryResponse {}
// ── Service ───────────────────────────────────────────────────────────
service ChannelService {
rpc GetChannel(GetChannelRequest) returns (GetChannelResponse);
rpc ListChannels(ListChannelsRequest) returns (ListChannelsResponse);
rpc CreateChannel(CreateChannelRequest) returns (CreateChannelResponse);
rpc UpdateChannel(UpdateChannelRequest) returns (UpdateChannelResponse);
rpc DeleteChannel(DeleteChannelRequest) returns (DeleteChannelResponse);
rpc GetChannelStats(GetChannelStatsRequest) returns (GetChannelStatsResponse);
rpc ListCategories(ListCategoriesRequest) returns (ListCategoriesResponse);
rpc CreateCategory(CreateCategoryRequest) returns (CreateCategoryResponse);
rpc UpdateCategory(UpdateCategoryRequest) returns (UpdateCategoryResponse);
rpc DeleteCategory(DeleteCategoryRequest) returns (DeleteCategoryResponse);
}
+412
View File
@@ -0,0 +1,412 @@
syntax = "proto3";
package appks.im.v1;
import "google/protobuf/timestamp.proto";
// ── ChannelMemberRole ──────────────────────────────────────────────────
message ChannelRole {
string id = 1;
string channel_id = 2;
string name = 3;
repeated string permissions = 4;
bool assignable = 5;
google.protobuf.Timestamp created_at = 6;
google.protobuf.Timestamp updated_at = 7;
}
message ListChannelRolesRequest { string channel_id = 1; }
message ListChannelRolesResponse { repeated ChannelRole roles = 1; }
message CreateChannelRoleRequest {
string channel_id = 1;
string name = 2;
repeated string permissions = 3;
bool assignable = 4;
}
message CreateChannelRoleResponse { ChannelRole role = 1; }
message UpdateChannelRoleRequest {
string role_id = 1;
optional string name = 2;
repeated string permissions = 3;
optional bool assignable = 4;
}
message UpdateChannelRoleResponse { ChannelRole role = 1; }
message DeleteChannelRoleRequest { string role_id = 1; }
message DeleteChannelRoleResponse {}
service ChannelRoleService {
rpc ListChannelRoles(ListChannelRolesRequest) returns (ListChannelRolesResponse);
rpc CreateChannelRole(CreateChannelRoleRequest) returns (CreateChannelRoleResponse);
rpc UpdateChannelRole(UpdateChannelRoleRequest) returns (UpdateChannelRoleResponse);
rpc DeleteChannelRole(DeleteChannelRoleRequest) returns (DeleteChannelRoleResponse);
}
// ── ChannelInvitation ──────────────────────────────────────────────────
message ChannelInvitation {
string id = 1;
string channel_id = 2;
string invited_by = 3;
string invited_user_id = 4;
string role = 5;
string status = 6;
google.protobuf.Timestamp created_at = 7;
google.protobuf.Timestamp updated_at = 8;
}
message ListInvitationsRequest { string channel_id = 1; }
message ListInvitationsResponse { repeated ChannelInvitation invitations = 1; }
message CreateInvitationRequest {
string channel_id = 1;
string invited_user_id = 2;
string role = 3;
}
message CreateInvitationResponse { ChannelInvitation invitation = 1; }
message AcceptInvitationRequest { string invitation_id = 1; }
message AcceptInvitationResponse { ChannelInvitation invitation = 1; }
message RevokeInvitationRequest { string invitation_id = 1; }
message RevokeInvitationResponse {}
service ChannelInvitationService {
rpc ListInvitations(ListInvitationsRequest) returns (ListInvitationsResponse);
rpc CreateInvitation(CreateInvitationRequest) returns (CreateInvitationResponse);
rpc AcceptInvitation(AcceptInvitationRequest) returns (AcceptInvitationResponse);
rpc RevokeInvitation(RevokeInvitationRequest) returns (RevokeInvitationResponse);
}
// ── ChannelWebhook ─────────────────────────────────────────────────────
message ChannelWebhook {
string id = 1;
string channel_id = 2;
string name = 3;
string url = 4;
string secret = 5;
repeated string events = 6;
bool active = 7;
google.protobuf.Timestamp created_at = 8;
google.protobuf.Timestamp updated_at = 9;
}
message ListWebhooksRequest { string channel_id = 1; }
message ListWebhooksResponse { repeated ChannelWebhook webhooks = 1; }
message CreateWebhookRequest {
string channel_id = 1;
string name = 2;
string url = 3;
optional string secret = 4;
repeated string events = 5;
}
message CreateWebhookResponse { ChannelWebhook webhook = 1; }
message UpdateWebhookRequest {
string webhook_id = 1;
optional string name = 2;
optional string url = 3;
optional string secret = 4;
repeated string events = 5;
optional bool active = 6;
}
message UpdateWebhookResponse { ChannelWebhook webhook = 1; }
message DeleteWebhookRequest { string webhook_id = 1; }
message DeleteWebhookResponse {}
service ChannelWebhookService {
rpc ListWebhooks(ListWebhooksRequest) returns (ListWebhooksResponse);
rpc CreateWebhook(CreateWebhookRequest) returns (CreateWebhookResponse);
rpc UpdateWebhook(UpdateWebhookRequest) returns (UpdateWebhookResponse);
rpc DeleteWebhook(DeleteWebhookRequest) returns (DeleteWebhookResponse);
}
// ── ChannelSlashCommand ────────────────────────────────────────────────
message ChannelSlashCommand {
string id = 1;
string channel_id = 2;
string command = 3;
string description = 4;
string request_url = 5;
repeated string scopes = 6;
google.protobuf.Timestamp created_at = 7;
google.protobuf.Timestamp updated_at = 8;
}
message ListSlashCommandsRequest { string channel_id = 1; }
message ListSlashCommandsResponse { repeated ChannelSlashCommand commands = 1; }
message CreateSlashCommandRequest {
string channel_id = 1;
string command = 2;
string description = 3;
string request_url = 4;
repeated string scopes = 5;
}
message CreateSlashCommandResponse { ChannelSlashCommand command = 1; }
message UpdateSlashCommandRequest {
string command_id = 1;
optional string description = 2;
optional string request_url = 3;
repeated string scopes = 4;
}
message UpdateSlashCommandResponse { ChannelSlashCommand command = 1; }
message DeleteSlashCommandRequest { string command_id = 1; }
message DeleteSlashCommandResponse {}
service ChannelSlashCommandService {
rpc ListSlashCommands(ListSlashCommandsRequest) returns (ListSlashCommandsResponse);
rpc CreateSlashCommand(CreateSlashCommandRequest) returns (CreateSlashCommandResponse);
rpc UpdateSlashCommand(UpdateSlashCommandRequest) returns (UpdateSlashCommandResponse);
rpc DeleteSlashCommand(DeleteSlashCommandRequest) returns (DeleteSlashCommandResponse);
}
// ── ChannelRepoLink ────────────────────────────────────────────────────
message ChannelRepoLink {
string id = 1;
string channel_id = 2;
string repo_id = 3;
string link_type = 4;
repeated string events = 5;
google.protobuf.Timestamp created_at = 6;
google.protobuf.Timestamp updated_at = 7;
}
message ListRepoLinksRequest { string channel_id = 1; }
message ListRepoLinksResponse { repeated ChannelRepoLink links = 1; }
message CreateRepoLinkRequest {
string channel_id = 1;
string repo_id = 2;
string link_type = 3;
repeated string events = 4;
}
message CreateRepoLinkResponse { ChannelRepoLink link = 1; }
message DeleteRepoLinkRequest { string link_id = 1; }
message DeleteRepoLinkResponse {}
service ChannelRepoLinkService {
rpc ListRepoLinks(ListRepoLinksRequest) returns (ListRepoLinksResponse);
rpc CreateRepoLink(CreateRepoLinkRequest) returns (CreateRepoLinkResponse);
rpc DeleteRepoLink(DeleteRepoLinkRequest) returns (DeleteRepoLinkResponse);
}
// ── ImIntegration ──────────────────────────────────────────────────────
message ImIntegration {
string id = 1;
string channel_id = 2;
string provider = 3;
string external_channel_id = 4;
string sync_direction = 5;
bool active = 6;
google.protobuf.Timestamp created_at = 7;
google.protobuf.Timestamp updated_at = 8;
}
message ListIntegrationsRequest { string channel_id = 1; }
message ListIntegrationsResponse { repeated ImIntegration integrations = 1; }
message CreateIntegrationRequest {
string channel_id = 1;
string provider = 2;
string external_channel_id = 3;
string sync_direction = 4;
}
message CreateIntegrationResponse { ImIntegration integration = 1; }
message UpdateIntegrationRequest {
string integration_id = 1;
optional string sync_direction = 2;
optional bool active = 3;
}
message UpdateIntegrationResponse { ImIntegration integration = 1; }
message DeleteIntegrationRequest { string integration_id = 1; }
message DeleteIntegrationResponse {}
service ImIntegrationService {
rpc ListIntegrations(ListIntegrationsRequest) returns (ListIntegrationsResponse);
rpc CreateIntegration(CreateIntegrationRequest) returns (CreateIntegrationResponse);
rpc UpdateIntegration(UpdateIntegrationRequest) returns (UpdateIntegrationResponse);
rpc DeleteIntegration(DeleteIntegrationRequest) returns (DeleteIntegrationResponse);
}
// ── CustomEmoji ────────────────────────────────────────────────────────
message CustomEmoji {
string id = 1;
string workspace_id = 2;
string name = 3;
string image_url = 4;
google.protobuf.Timestamp created_at = 5;
}
message ListCustomEmojisRequest { string workspace_id = 1; }
message ListCustomEmojisResponse { repeated CustomEmoji emojis = 1; }
message CreateCustomEmojiRequest {
string workspace_id = 1;
string name = 2;
string image_url = 3;
}
message CreateCustomEmojiResponse { CustomEmoji emoji = 1; }
message DeleteCustomEmojiRequest { string emoji_id = 1; }
message DeleteCustomEmojiResponse {}
service CustomEmojiService {
rpc ListCustomEmojis(ListCustomEmojisRequest) returns (ListCustomEmojisResponse);
rpc CreateCustomEmoji(CreateCustomEmojiRequest) returns (CreateCustomEmojiResponse);
rpc DeleteCustomEmoji(DeleteCustomEmojiRequest) returns (DeleteCustomEmojiResponse);
}
// ── ForumTag ───────────────────────────────────────────────────────────
message ForumTag {
string id = 1;
string channel_id = 2;
string name = 3;
bool moderated = 4;
int32 position = 5;
google.protobuf.Timestamp created_at = 6;
google.protobuf.Timestamp updated_at = 7;
}
message ListForumTagsRequest { string channel_id = 1; }
message ListForumTagsResponse { repeated ForumTag tags = 1; }
message CreateForumTagRequest {
string channel_id = 1;
string name = 2;
bool moderated = 3;
optional int32 position = 4;
}
message CreateForumTagResponse { ForumTag tag = 1; }
message UpdateForumTagRequest {
string tag_id = 1;
optional string name = 2;
optional bool moderated = 3;
optional int32 position = 4;
}
message UpdateForumTagResponse { ForumTag tag = 1; }
message DeleteForumTagRequest { string tag_id = 1; }
message DeleteForumTagResponse {}
service ForumTagService {
rpc ListForumTags(ListForumTagsRequest) returns (ListForumTagsResponse);
rpc CreateForumTag(CreateForumTagRequest) returns (CreateForumTagResponse);
rpc UpdateForumTag(UpdateForumTagRequest) returns (UpdateForumTagResponse);
rpc DeleteForumTag(DeleteForumTagRequest) returns (DeleteForumTagResponse);
}
// ── VoiceParticipant ───────────────────────────────────────────────────
message VoiceParticipant {
string id = 1;
string channel_id = 2;
string user_id = 3;
bool muted = 4;
bool deafened = 5;
google.protobuf.Timestamp joined_at = 6;
}
message ListVoiceParticipantsRequest { string channel_id = 1; }
message ListVoiceParticipantsResponse { repeated VoiceParticipant participants = 1; }
message UpdateVoiceStateRequest {
string channel_id = 1;
string user_id = 2;
optional bool muted = 3;
optional bool deafened = 4;
}
message UpdateVoiceStateResponse { VoiceParticipant participant = 1; }
service VoiceService {
rpc ListVoiceParticipants(ListVoiceParticipantsRequest) returns (ListVoiceParticipantsResponse);
rpc UpdateVoiceState(UpdateVoiceStateRequest) returns (UpdateVoiceStateResponse);
}
// ── Stage ──────────────────────────────────────────────────────────────
message Stage {
string id = 1;
string channel_id = 2;
string topic = 3;
string privacy_level = 4;
bool discoverable = 5;
google.protobuf.Timestamp started_at = 6;
google.protobuf.Timestamp ended_at = 7;
google.protobuf.Timestamp created_at = 8;
google.protobuf.Timestamp updated_at = 9;
}
message GetStageRequest { string channel_id = 1; }
message GetStageResponse { Stage stage = 1; }
message CreateStageRequest {
string channel_id = 1;
string topic = 2;
string privacy_level = 3;
bool discoverable = 4;
}
message CreateStageResponse { Stage stage = 1; }
message UpdateStageRequest {
string stage_id = 1;
optional string topic = 2;
optional string privacy_level = 3;
optional bool discoverable = 4;
}
message UpdateStageResponse { Stage stage = 1; }
message DeleteStageRequest { string stage_id = 1; }
message DeleteStageResponse {}
service StageService {
rpc GetStage(GetStageRequest) returns (GetStageResponse);
rpc CreateStage(CreateStageRequest) returns (CreateStageResponse);
rpc UpdateStage(UpdateStageRequest) returns (UpdateStageResponse);
rpc DeleteStage(DeleteStageRequest) returns (DeleteStageResponse);
}
// ── ChannelEvent (Audit Log) ───────────────────────────────────────────
message ChannelAuditEvent {
string id = 1;
string channel_id = 2;
string actor_id = 3;
string event_type = 4;
string target_type = 5;
string target_id = 6;
optional string old_value = 7;
optional string new_value = 8;
google.protobuf.Timestamp created_at = 9;
}
message ListChannelEventsRequest {
string channel_id = 1;
int32 limit = 2;
int32 offset = 3;
}
message ListChannelEventsResponse {
repeated ChannelAuditEvent events = 1;
int32 total = 2;
}
service ChannelAuditService {
rpc ListChannelEvents(ListChannelEventsRequest) returns (ListChannelEventsResponse);
}
+131
View File
@@ -0,0 +1,131 @@
syntax = "proto3";
package appks.im.v1;
import "google/protobuf/timestamp.proto";
// Member management service for the IM microservice.
// Provides CRUD for channel members, join/leave, and membership checks.
// ── Enums ──────────────────────────────────────────────────────────────
enum Role {
ROLE_UNSPECIFIED = 0;
ROLE_OWNER = 1;
ROLE_ADMIN = 2;
ROLE_MAINTAINER = 3;
ROLE_MODERATOR = 4;
ROLE_MEMBER = 5;
ROLE_CONTRIBUTOR = 6;
ROLE_VIEWER = 7;
ROLE_GUEST = 8;
ROLE_BOT = 9;
}
enum MemberStatus {
MEMBER_STATUS_UNSPECIFIED = 0;
MEMBER_STATUS_ACTIVE = 1;
MEMBER_STATUS_INVITED = 2;
MEMBER_STATUS_LEFT = 3;
MEMBER_STATUS_KICKED = 4;
MEMBER_STATUS_BANNED = 5;
}
// ── Messages ───────────────────────────────────────────────────────────
message ChannelMember {
string id = 1;
string channel_id = 2;
string user_id = 3;
string role = 4;
string status = 5;
bool muted = 6;
bool pinned = 7;
optional string last_read_message_id = 8;
optional google.protobuf.Timestamp last_read_at = 9;
optional google.protobuf.Timestamp joined_at = 10;
optional google.protobuf.Timestamp left_at = 11;
google.protobuf.Timestamp created_at = 12;
google.protobuf.Timestamp updated_at = 13;
}
// ── Requests / Responses ──────────────────────────────────────────────
message ListMembersRequest {
string channel_id = 1;
optional string status = 2;
int32 limit = 3;
int32 offset = 4;
}
message ListMembersResponse {
repeated ChannelMember members = 1;
int32 total = 2;
}
message InviteMemberRequest {
string channel_id = 1;
string user_id = 2;
optional string role = 3;
}
message InviteMemberResponse {
ChannelMember member = 1;
}
message UpdateMemberRequest {
string channel_id = 1;
string user_id = 2;
optional string role = 3;
optional bool muted = 4;
optional bool pinned = 5;
}
message UpdateMemberResponse {
ChannelMember member = 1;
}
message KickMemberRequest {
string channel_id = 1;
string user_id = 2;
}
message KickMemberResponse {}
message JoinChannelRequest {
string channel_id = 1;
string user_id = 2;
}
message JoinChannelResponse {
ChannelMember member = 1;
}
message LeaveChannelRequest {
string channel_id = 1;
string user_id = 2;
}
message LeaveChannelResponse {}
message IsMemberRequest {
string channel_id = 1;
string user_id = 2;
}
message IsMemberResponse {
bool is_member = 1;
string role = 2;
}
// ── Service ───────────────────────────────────────────────────────────
service MemberService {
rpc ListMembers(ListMembersRequest) returns (ListMembersResponse);
rpc InviteMember(InviteMemberRequest) returns (InviteMemberResponse);
rpc UpdateMember(UpdateMemberRequest) returns (UpdateMemberResponse);
rpc KickMember(KickMemberRequest) returns (KickMemberResponse);
rpc JoinChannel(JoinChannelRequest) returns (JoinChannelResponse);
rpc LeaveChannel(LeaveChannelRequest) returns (LeaveChannelResponse);
rpc IsMember(IsMemberRequest) returns (IsMemberResponse);
}
+128
View File
@@ -0,0 +1,128 @@
syntax = "proto3";
package appks.im.v1;
// IM-specific permissions for channel operations.
// Separate from the general Permission enum used for repo/workspace access.
enum ImPermission {
IM_PERMISSION_UNSPECIFIED = 0;
IM_PERMISSION_READ_CHANNEL = 1;
IM_PERMISSION_SEND_MESSAGE = 2;
IM_PERMISSION_MANAGE_THREADS = 3;
IM_PERMISSION_MANAGE_REACTIONS = 4;
IM_PERMISSION_MANAGE_PINS = 5;
IM_PERMISSION_INVITE_MEMBERS = 6;
IM_PERMISSION_KICK_MEMBERS = 7;
IM_PERMISSION_MANAGE_CHANNEL = 8;
IM_PERMISSION_MANAGE_ROLES = 9;
IM_PERMISSION_MANAGE_WEBHOOKS = 10;
IM_PERMISSION_MANAGE_EMOJIS = 11;
IM_PERMISSION_VIEW_AUDIT_LOG = 12;
IM_PERMISSION_MANAGE_INTEGRATIONS = 13;
IM_PERMISSION_SEND_TTS = 14;
IM_PERMISSION_USE_SLASH_COMMANDS = 15;
IM_PERMISSION_ATTACH_FILES = 16;
IM_PERMISSION_MENTION_EVERYONE = 17;
IM_PERMISSION_MANAGE_MESSAGES = 18;
IM_PERMISSION_ADMIN = 19;
}
// ── Messages ───────────────────────────────────────────────────────────
message PermissionOverwrite {
string id = 1;
string channel_id = 2;
string target_type = 3;
string target_id = 4;
repeated ImPermission allow = 5;
repeated ImPermission deny = 6;
string created_at = 7;
string updated_at = 8;
}
// ── Requests / Responses ──────────────────────────────────────────────
message CheckPermissionRequest {
string channel_id = 1;
string user_id = 2;
ImPermission permission = 3;
}
message CheckPermissionResponse {
bool allowed = 1;
string role = 2;
}
message GetPermissionsRequest {
string channel_id = 1;
string user_id = 2;
}
message GetPermissionsResponse {
repeated ImPermission permissions = 1;
string role = 2;
}
message SetPermissionOverwriteRequest {
string channel_id = 1;
string target_type = 2;
string target_id = 3;
repeated ImPermission allow = 4;
repeated ImPermission deny = 5;
}
message SetPermissionOverwriteResponse {
PermissionOverwrite overwrite = 1;
}
message GetPermissionOverwritesRequest {
string channel_id = 1;
}
message GetPermissionOverwritesResponse {
repeated PermissionOverwrite overwrites = 1;
}
message DeletePermissionOverwriteRequest {
string channel_id = 1;
string target_type = 2;
string target_id = 3;
}
message DeletePermissionOverwriteResponse {}
message ResolveChannelRequest {
string channel_id = 1;
}
message ResolveChannelResponse {
string channel_id = 1;
string workspace_id = 2;
string name = 3;
string visibility = 4;
string channel_type = 5;
bool read_only = 6;
bool archived = 7;
optional string created_by = 8;
}
message EnsureReadableRequest {
string channel_id = 1;
string user_id = 2;
}
message EnsureReadableResponse {
bool allowed = 1;
}
// ── Service ───────────────────────────────────────────────────────────
service PermissionService {
rpc CheckPermission(CheckPermissionRequest) returns (CheckPermissionResponse);
rpc GetPermissions(GetPermissionsRequest) returns (GetPermissionsResponse);
rpc SetPermissionOverwrite(SetPermissionOverwriteRequest) returns (SetPermissionOverwriteResponse);
rpc GetPermissionOverwrites(GetPermissionOverwritesRequest) returns (GetPermissionOverwritesResponse);
rpc DeletePermissionOverwrite(DeletePermissionOverwriteRequest) returns (DeletePermissionOverwriteResponse);
rpc ResolveChannel(ResolveChannelRequest) returns (ResolveChannelResponse);
rpc EnsureReadable(EnsureReadableRequest) returns (EnsureReadableResponse);
}
+247
View File
@@ -0,0 +1,247 @@
syntax = "proto3";
package appks.v1;
import "google/protobuf/timestamp.proto";
// Repository-related services for gitshell.
// gitshell calls these RPCs to:
// 1. Check branch protection rules before accepting a push.
// 2. Locate which storage node hosts a given repository.
// 3. Verify user/agent permissions on a repository.
// 4. Acquire / release push locks for concurrency control.
// ── Enums ──────────────────────────────────────────────────────────────
enum PushLockStatus {
PUSH_LOCK_STATUS_UNSPECIFIED = 0;
PUSH_LOCK_STATUS_QUEUED = 1;
PUSH_LOCK_STATUS_ACTIVE = 2;
PUSH_LOCK_STATUS_FINISHED = 3;
PUSH_LOCK_STATUS_FAILED = 4;
}
enum MergeStrategy {
MERGE_STRATEGY_UNSPECIFIED = 0;
MERGE_STRATEGY_MERGE = 1;
MERGE_STRATEGY_SQUASH = 2;
MERGE_STRATEGY_REBASE = 3;
MERGE_STRATEGY_FAST_FORWARD = 4;
}
// ── Branch Protection ──────────────────────────────────────────────────
message BranchProtectionRule {
string id = 1;
string repo_id = 2;
string pattern = 3;
int32 require_approvals = 4;
bool require_status_checks = 5;
repeated string required_status_checks = 6;
bool require_linear_history = 7;
bool allow_force_pushes = 8;
bool allow_deletions = 9;
bool require_signed_commits = 10;
bool require_code_owner_review = 11;
bool dismiss_stale_reviews = 12;
bool restrict_pushes = 13;
repeated string push_allowances = 14;
bool restrict_review_dismissal = 15;
repeated string dismissal_allowances = 16;
bool require_conversation_resolution = 17;
}
message CheckBranchProtectionRequest {
string workspace_name = 1;
string repo_name = 2;
string branch_name = 3;
// The user attempting the push (for push-allowance checks).
optional string user_id = 4;
}
message CheckBranchProtectionResponse {
bool protected = 1;
BranchProtectionRule rule = 2;
// Human-readable reasons why the push would be blocked.
repeated string block_reasons = 3;
// Whether the given user is exempt (in push_allowances).
bool user_allowed = 4;
}
// ── Repository Locate ─────────────────────────────────────────────────
message StorageNode {
string node_id = 1;
string address = 2;
// Labels for routing decisions (e.g. region, disk-type).
map<string, string> labels = 3;
bool healthy = 4;
}
message LocateRepositoryRequest {
string workspace_name = 1;
string repo_name = 2;
}
message LocateRepositoryResponse {
bool found = 1;
string repo_id = 2;
// The storage path on the node (e.g. "ab/cd/12345.git").
string storage_path = 3;
// Primary storage node that hosts the repository.
StorageNode primary_node = 4;
// Additional replica / failover nodes.
repeated StorageNode replica_nodes = 5;
}
// ── Permission Check ──────────────────────────────────────────────────
message PermissionScope {
string scope = 1; // e.g. "repo:read", "repo:write"
optional string resource = 2; // e.g. specific repo name if scoped
}
message CheckRepoPermissionRequest {
string workspace_name = 1;
string repo_name = 2;
// The principal to check — either a user_id or a deploy_key_id.
oneof principal {
string user_id = 3;
string deploy_key_id = 4;
}
// The required permission level.
string required_permission = 5;
}
message CheckRepoPermissionResponse {
bool allowed = 1;
// The actual resolved permission (may be higher than required).
string resolved_permission = 2;
// If not allowed, a human-readable reason.
string reason = 3;
}
// ── Push Lock ──────────────────────────────────────────────────────────
message PushLock {
string id = 1;
string repo_id = 2;
string pusher_id = 3;
string ref_name = 4;
PushLockStatus status = 5;
int32 queue_position = 6;
google.protobuf.Timestamp queued_at = 7;
google.protobuf.Timestamp started_at = 8;
google.protobuf.Timestamp finished_at = 9;
string storage_node_id = 10;
string lease_token = 11;
string error_message = 12;
}
message AcquirePushLockRequest {
string workspace_name = 1;
string repo_name = 2;
string ref_name = 3;
string pusher_id = 4;
}
message AcquirePushLockResponse {
bool acquired = 1;
PushLock lock = 2;
// If not immediately acquired, estimated wait in seconds.
int32 estimated_wait_seconds = 3;
string error = 4;
}
message ReleasePushLockRequest {
string lock_id = 1;
// Must match the lease_token from AcquirePushLock.
string lease_token = 2;
// Whether the push succeeded.
bool success = 3;
optional string error_message = 4;
}
message ReleasePushLockResponse {
bool released = 1;
string error = 2;
}
message GetPushLockRequest {
string lock_id = 1;
}
message GetPushLockResponse {
PushLock lock = 1;
}
message ListPushLocksRequest {
string workspace_name = 1;
string repo_name = 2;
// Filter by status; if unspecified, returns all active locks.
optional PushLockStatus status = 3;
}
message ListPushLocksResponse {
repeated PushLock locks = 1;
}
// ── Repository Metadata ───────────────────────────────────────────────
message RepoInfo {
string id = 1;
string workspace_id = 2;
string owner_id = 3;
string name = 4;
optional string description = 5;
string default_branch = 6;
string visibility = 7;
string status = 8;
bool is_fork = 9;
optional string forked_from_repo_id = 10;
string storage_path = 11;
string git_service = 12;
google.protobuf.Timestamp archived_at = 13;
google.protobuf.Timestamp created_at = 14;
google.protobuf.Timestamp updated_at = 15;
}
message GetRepoInfoRequest {
string workspace_name = 1;
string repo_name = 2;
}
message GetRepoInfoResponse {
bool found = 1;
RepoInfo repo = 2;
}
// ── Service ────────────────────────────────────────────────────────────
service RepoService {
// ── Branch Protection ──
// Check whether a branch is protected and whether a push is allowed.
rpc CheckBranchProtection(CheckBranchProtectionRequest) returns (CheckBranchProtectionResponse);
// ── Repository Locate ──
// Find which storage node(s) host a repository.
rpc LocateRepository(LocateRepositoryRequest) returns (LocateRepositoryResponse);
// ── Permission Check ──
// Verify that a user or deploy key has the required permission on a repo.
rpc CheckRepoPermission(CheckRepoPermissionRequest) returns (CheckRepoPermissionResponse);
// ── Push Lock ──
// Acquire an exclusive push lock for a ref.
rpc AcquirePushLock(AcquirePushLockRequest) returns (AcquirePushLockResponse);
// Release a previously acquired push lock.
rpc ReleasePushLock(ReleasePushLockRequest) returns (ReleasePushLockResponse);
// Get the current state of a push lock.
rpc GetPushLock(GetPushLockRequest) returns (GetPushLockResponse);
// List active push locks for a repository.
rpc ListPushLocks(ListPushLocksRequest) returns (ListPushLocksResponse);
// ── Repository Metadata ──
// Get lightweight repository metadata (for gitshell to resolve repo names).
rpc GetRepoInfo(GetRepoInfoRequest) returns (GetRepoInfoResponse);
}