# ghr-stats configuration — copy to ~/.config/ghr-stats/config.toml
#
#   install -Dm600 config.example.toml ~/.config/ghr-stats/config.toml
#
# Every field has a default, so the tool runs with no config at all. It holds
# GitHub tokens, so it is root-owned mode 0600.
#
# Canonical location: /etc/ghr-stats/config.toml (system-scope, root:root 0600) —
# one source of truth the collector reads and `sudo ghr-stats config` writes.
# An explicit --config FLAG or $GHR_STATS_CONFIG overrides it.

# SQLite database (the collector service writes it; the TUI reads it over the IPC socket).
# Default: $XDG_DATA_HOME/ghr-stats/ghr-stats.db (~/.local/share/...).
# db_path = "/home/you/.local/share/ghr-stats/ghr-stats.db"

# Directories scanned for runner installs (each holds a `.runner` file).
# Default: empty — `ghr-stats config` discovers and records them, or list here.
# runner_roots = ["/opt/actions-runner", "/srv/runners"]

# GitHub orgs to reconcile. Empty => derived from the orgs found in `.runner`.
# orgs = ["gh-org-a", "gh-org-b"]

[intervals]
# Local sampling cadence (runner processes / cgroup / host), seconds.
local_secs = 5
# GitHub API reconcile cadence, seconds (floored at 10).
api_secs = 60

# ── GitHub API (optional, read-only) ───────────────────────────────────────
# Runner online/busy reconcile; `ghr-stats config` validates each token.
#
# ORGANIZATION runners only: the reconcile calls /orgs/{org}/actions/runners,
# gated by the ORG-scoped "Self-hosted runners" fine-grained-PAT permission —
# which exists only on an organization resource owner. Personal-account
# (repository-level) self-hosted runners have no equivalent PAT permission, so
# they get no GitHub online/busy reconcile; they are still sampled locally
# (liveness / CPU / memory / uptime — no PAT needed).
#
# Create a FINE-GRAINED personal access token PER ORG (a fine-grained PAT is
# scoped to one resource owner):
#   GitHub → Settings → Developer settings → Personal access tokens →
#   Fine-grained tokens → Generate new token
#     • Resource owner: the organization
#     • Repository access: none / public read-only (runner data is org-scoped)
#     • Organization permissions → "Self-hosted runners" → Read-only   (required)
#     • Repository permissions → "Actions" → Read-only   (OPTIONAL: lets the
#       collector fill each job's success/failure conclusion; without it jobs
#       still show timing, just a neutral "done")
#     • Expiration: bounded (e.g. 90 days); re-mint on expiry
# The org may require owner approval for the token.
#
# [github.tokens]
# "gh-org-a"      = "github_pat_..."
# "gh-org-b"      = "github_pat_..."
#
# Single fallback for any org without a specific token above (suits a single-org
# setup). The GHR_STATS_GITHUB_TOKEN env var overrides this fallback.
# [github]
# token = "github_pat_..."

# ── Metrics (optional) ───────────────────────────────────────────────────────
# The collector service can also expose the fleet metrics. Both off by default.

# Prometheus PULL: a tiny /metrics endpoint scrapers hit.
# [metrics.pull]
# enabled = true
# SECURITY: bind loopback only (default 127.0.0.1:9477). Never bind a wider
# interface — the metrics are unauthenticated. Use `localhost`? No: always the
# literal 127.0.0.1 (localhost can resolve to ::1 first and hang the listener).
# addr = "127.0.0.1:9477"

# PUSH: periodically POST the metrics as JSON to an ingest endpoint (e.g.
# OpenObserve's _json API). `auth` is sent as the Authorization header.
# [metrics.push]
# enabled = true
# endpoint = "https://observe.example.com/api/default/ghr_stats/_json"
# auth = "Basic dXNlcjpwYXNz"
# interval_secs = 30
