Separate saved run schedules from pipeline definitions

This commit is contained in:
2026-10-21 00:47:56 +01:00
parent 366931eeec
commit 4d8b34939d
20 changed files with 1391 additions and 336 deletions
+13 -6
View File
@@ -94,12 +94,15 @@ type PipelineDetail struct {
}
type PipelineSummary struct {
ID int64 `json:"id"`
Name string `json:"name"`
Version int `json:"version"`
Stages int `json:"stages"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
Scheduled bool `json:"scheduled"`
ScheduleCount int `json:"schedule_count"`
EnabledScheduleCount int `json:"enabled_schedule_count"`
ID int64 `json:"id"`
Name string `json:"name"`
Version int `json:"version"`
Stages int `json:"stages"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
// Shape is the current version's parsed graph, included so a list can draw
// a miniature without one detail request per row. Detail responses keep the
// full Graph field; this one is deliberately optional and additive.
@@ -113,6 +116,10 @@ type PipelineSummary struct {
// are optional so older peers ignore them. See search.go for the per-type payloads
// and the ranking/kind/bound vocabulary.
type Message struct {
Schedule *SavedSchedule `json:"schedule,omitempty"`
Schedules []SavedSchedule `json:"schedules,omitempty"`
ScheduleID int64 `json:"schedule_id,omitempty"`
ExpectedRevision int64 `json:"expected_revision,omitempty"`
DefaultHarness string `json:"default_harness,omitempty"`
Build *buildinfo.Info `json:"build,omitempty"`
Protocol int `json:"protocol,omitempty"`
+3
View File
@@ -25,6 +25,9 @@ const (
// from the frame instead of re-reading the whole list. They repeat on every
// frame (pipeline identity never changes mid-run).
type RunEventFrame struct {
Scheduled bool `json:"scheduled"`
ScheduleID int64 `json:"schedule_id,omitempty"`
ScheduleName string `json:"schedule_name,omitempty"`
// SessionExportUpdated requests a detail refresh even when the stage/run
// outcome is unchanged. It never fabricates a second stage completion.
SessionExportUpdated bool `json:"session_export_updated,omitempty"`
+1 -1
View File
@@ -21,7 +21,7 @@ func TestRunEventGoldenJSON(t *testing.T) {
if err != nil {
t.Fatal(err)
}
want := `{"run_id":7,"workspace":"/work","pipeline_id":4,"name":"release","title":"Ship it","version":3,"status":"running","current_stage":"build","completed_steps":1,"created_at":"2026-01-02T03:04:05Z","artifacts":2,"step":{"sequence":2,"stage":"build","status":"completed","outcome":"success","target":"#success","artifacts":2}}`
want := `{"scheduled":false,"run_id":7,"workspace":"/work","pipeline_id":4,"name":"release","title":"Ship it","version":3,"status":"running","current_stage":"build","completed_steps":1,"created_at":"2026-01-02T03:04:05Z","artifacts":2,"step":{"sequence":2,"stage":"build","status":"completed","outcome":"success","target":"#success","artifacts":2}}`
if string(encoded) != want {
t.Fatalf("golden mismatch\n got %s\nwant %s", encoded, want)
}
+3
View File
@@ -134,6 +134,9 @@ type SessionExportRecovery struct {
}
type RunSummary struct {
Scheduled bool `json:"scheduled"`
ScheduleID int64 `json:"schedule_id,omitempty"`
ScheduleName string `json:"schedule_name,omitempty"`
GraphEvidence *RunGraphEvidence `json:"graph_evidence,omitempty"`
NotifyMode string `json:"notify_mode,omitempty"`
ID int64 `json:"id"`
+32
View File
@@ -0,0 +1,32 @@
package protocol
const (
ListSchedules = "list_schedules"
Schedules = "schedules"
SaveSchedule = "save_schedule"
SavedScheduleReply = "schedule"
DeleteSchedule = "delete_schedule"
ScheduleDeleted = "schedule_deleted"
)
// SavedSchedule pairs an immutable pipeline version with a complete run request.
// Revision is the compare-and-swap token for edits and deletion; zero creates.
type SavedSchedule struct {
ID int64 `json:"id"`
Revision int64 `json:"revision"`
Name string `json:"name"`
PipelineID int64 `json:"pipeline_id"`
Version int `json:"version"`
Enabled bool `json:"enabled"`
Input map[string]any `json:"input"`
Workspace string `json:"workspace"`
Model string `json:"model,omitempty"`
StageModels map[string]string `json:"stage_models,omitempty"`
NotifyMode string `json:"notify_mode,omitempty"`
Title string `json:"title,omitempty"`
OutputFormat string `json:"output_format,omitempty"`
Rule Schedule `json:"rule"`
NextDue string `json:"next_due"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}