// Copyright (C) 2026 Yota Hamada
// SPDX-License-Identifier: GPL-3.0-or-later

syntax = "proto3";

package index.v1;

// protolint:disable:next MAX_LINE_LENGTH
option go_package = "github.com/dagucloud/dagu/proto/index/v1;indexv1";

// DAGIndex stores cached metadata for DAG definition files.
message DAGIndex {
  uint32 version = 1;
  int64 built_at_unix = 2;
  repeated DAGIndexEntry entries = 3;
}

// DAGIndexEntry holds cached metadata for a single DAG definition file.
message DAGIndexEntry {
  string file_path = 1;
  int64 file_size = 2;
  int64 mod_time = 3;
  string name = 4;
  repeated string labels = 5;
  string group = 6;
  string schedule = 7;
  bool suspended = 8;
  string description = 9;
  string load_error = 10;
}

// DAGRunIndex stores cached summaries for a single day's DAG runs.
message DAGRunIndex {
  uint32 version = 1;
  int64 built_at_unix = 2;
  repeated DAGRunIndexEntry entries = 3;
}

// DAGRunIndexEntry holds a cached summary for a single DAG run.
message DAGRunIndexEntry {
  string dag_run_dir = 1;
  string dag_run_id = 2;
  string latest_attempt_dir = 3;
  int64 latest_status_size = 4;
  int64 latest_status_mod_time = 5;
  int32 status = 6;
  int64 started_at = 7;     // Unix epoch seconds
  int64 finished_at = 8;    // Unix epoch seconds
  repeated string labels = 9;
  int64 run_dir_mod_time = 10;
  string worker_id = 11;
  string params = 12;
  string queued_at = 13;    // RFC 3339 string (matches DAGRunStatus.QueuedAt)
  int32 trigger_type = 14;
  int64 created_at = 15;    // Unix epoch milliseconds (matches DAGRunStatus.CreatedAt)
  string name = 16;
  string schedule_time = 17;  // RFC 3339 string (matches DAGRunStatus.ScheduleTime)
  string attempt_id = 18;
  int32 auto_retry_count = 19;
  string parent_dag_run_name = 20;
  string parent_dag_run_id = 21;
  int32 auto_retry_limit = 22;
  int64 auto_retry_interval = 23;      // Duration in nanoseconds
  double auto_retry_backoff = 24;
  int64 auto_retry_max_interval = 25;  // Duration in nanoseconds
  string proc_group = 26;
  string suspend_flag_name = 27;
  string archive_dir = 28;
}
