Files
archie/proto/state/v1/schedule.proto
T
sam cc5789eb5f feat(scheduling): schedules and runs in the State Store with grid timing and run history
Schedules leave the schedules control-plane resource for State Store tables
behind a ScheduleService contract. A run is claimed per schedule slot, missed
slots fire once, the next run stays on the schedule's grid, cron is read in the
schedule-settings time zone, and failed runs are recorded and advance. Three
failures in a row raise a schedule.failing alert. A fired run records a
schedule-fired capture. Run history is pruned by age and count.

Removes the chat and spawn-task runners, the dangerous-payload guard and the
old schedules settings page.
2026-10-26 00:49:24 +11:00

138 lines
3.7 KiB
Protocol Buffer

syntax = "proto3";
package state.v1;
import "google/protobuf/timestamp.proto";
// Schedules and their runs (internal/domain/scheduling). The scheduler in
// archied claims due runs and records their results; the dashboard edits
// schedules and reads runs. Cron is read in the instance zone from the
// schedule-settings resource.
service ScheduleService {
rpc ListSchedules(ListSchedulesRequest) returns (ListSchedulesResponse);
rpc GetSchedule(GetScheduleRequest) returns (GetScheduleResponse);
rpc PutSchedule(PutScheduleRequest) returns (PutScheduleResponse);
rpc DeleteSchedule(DeleteScheduleRequest) returns (DeleteScheduleResponse);
rpc EnsureBuiltinSchedules(EnsureBuiltinSchedulesRequest) returns (EnsureBuiltinSchedulesResponse);
rpc ClaimDueRuns(ClaimDueRunsRequest) returns (ClaimDueRunsResponse);
rpc RequestScheduleRun(RequestScheduleRunRequest) returns (RequestScheduleRunResponse);
rpc FinishScheduleRun(FinishScheduleRunRequest) returns (FinishScheduleRunResponse);
rpc SetScheduleRunCapture(SetScheduleRunCaptureRequest) returns (SetScheduleRunCaptureResponse);
rpc ListScheduleRuns(ListScheduleRunsRequest) returns (ListScheduleRunsResponse);
}
message ScheduleOwner {
// kind is "instance" or "org".
string kind = 1;
// id is the organisation id for an org owner, empty for the instance.
string id = 2;
}
message ScheduleTiming {
// kind is "interval", "cron" or "once".
string kind = 1;
int64 interval_seconds = 2;
string cron = 3;
google.protobuf.Timestamp at = 4;
google.protobuf.Timestamp start = 5;
}
message Schedule {
string id = 1;
string name = 2;
ScheduleOwner owner = 3;
bool enabled = 4;
bool built_in = 5;
ScheduleTiming timing = 6;
google.protobuf.Timestamp next_run = 7;
google.protobuf.Timestamp created = 8;
google.protobuf.Timestamp updated = 9;
ScheduleRun last_run = 10;
}
message ScheduleRun {
int64 id = 1;
string schedule_id = 2;
google.protobuf.Timestamp scheduled_for = 3;
google.protobuf.Timestamp started = 4;
google.protobuf.Timestamp finished = 5;
// result is pending, running, succeeded, failed or skipped.
string result = 6;
string error = 7;
string capture_id = 8;
}
message ScheduleClaim {
ScheduleRun run = 1;
string name = 2;
bool built_in = 3;
}
message ListSchedulesRequest {}
message ListSchedulesResponse {
repeated Schedule schedules = 1;
}
message GetScheduleRequest {
string id = 1;
}
message GetScheduleResponse {
Schedule schedule = 1;
}
message PutScheduleRequest {
Schedule schedule = 1;
}
message PutScheduleResponse {
Schedule schedule = 1;
}
message DeleteScheduleRequest {
string id = 1;
}
message DeleteScheduleResponse {}
message BuiltinSchedule {
string id = 1;
string name = 2;
int64 interval_seconds = 3;
}
message EnsureBuiltinSchedulesRequest {
repeated BuiltinSchedule builtins = 1;
}
message EnsureBuiltinSchedulesResponse {}
message ClaimDueRunsRequest {
google.protobuf.Timestamp now = 1;
// stale_seconds fails a run still running after this long.
int64 stale_seconds = 2;
}
message ClaimDueRunsResponse {
repeated ScheduleClaim claims = 1;
}
message RequestScheduleRunRequest {
string id = 1;
}
message RequestScheduleRunResponse {
ScheduleRun run = 1;
}
message FinishScheduleRunRequest {
int64 run_id = 1;
string result = 2;
string error = 3;
}
message FinishScheduleRunResponse {
// failure_streak is how many of the schedule's latest finished runs failed
// in a row.
int64 failure_streak = 1;
}
message SetScheduleRunCaptureRequest {
int64 run_id = 1;
string capture_id = 2;
}
message SetScheduleRunCaptureResponse {}
message ListScheduleRunsRequest {
string schedule_id = 1;
int32 limit = 2;
}
message ListScheduleRunsResponse {
repeated ScheduleRun runs = 1;
}