Files
DocsGPT/docsgpt/core/settings/scheduler.py
T
arc53-machine c17b23378e refactor(settings): split Settings into per-domain modules
docsgpt/core/settings.py had grown to 258 fields in one 600-line class,
touched by about two commits a week, with related settings scattered
(GitHub ingest caps inside the embeddings block, API keys in four places,
the OpenAI Responses knobs 100 lines from the other OpenAI fields).

It is now a package: one module per domain (auth, llm, embeddings,
retrieval, vectorstores, database, workers, ingestion, ocr, storage,
connectors, server, events, agents, guardrails, scheduler, sandbox,
speech), each a SettingsGroup owning its fields and validators, composed
by multiple inheritance into the same flat Settings class. Every
attribute name, type, default, alias and constraint is unchanged, so
settings.NAME reads, .env files and test monkeypatches all keep working;
the import path docsgpt.core.settings is the package. Settings.normalize_api_key
is kept as a classmethod for callers that reuse it.

The comment above or beside each field became its Field(description=...),
so the definitions are visible to tooling; the next commit generates the
docs reference from them.

Pitfall recorded for future groups: pydantic collects validators by
method name across the MRO, so two groups naming a validator the same
would silently keep only one. Each group's validator has a unique name.
2026-09-17 11:04:01 +01:00

29 lines
1.3 KiB
Python

"""Scheduled agent runs (see scheduler.md)."""
from __future__ import annotations
from pydantic import Field
from docsgpt.core.settings._shared import SettingsGroup
class SchedulerSettings(SettingsGroup):
"""Cadence, quotas and timeouts of scheduled runs."""
SCHEDULE_DISPATCHER_INTERVAL: int = Field(
default=30, description="Seconds between dispatcher passes that enqueue due schedules."
)
SCHEDULE_MIN_INTERVAL: int = Field(default=900, description="Smallest allowed recurrence interval in seconds.")
SCHEDULE_MAX_PER_USER: int = Field(default=50, description="Cap on schedules a user may own.")
SCHEDULE_RUN_TIMEOUT: int = Field(default=600, description="Wall-clock cap on one scheduled run, in seconds.")
SCHEDULE_MISFIRE_GRACE: int = Field(
default=60, description="Seconds past the due time within which a missed run still fires."
)
SCHEDULE_AUTOPAUSE_FAILURES: int = Field(
default=3, description="Consecutive failures after which a schedule is paused automatically."
)
SCHEDULE_ONCE_MAX_HORIZON: int = Field(
default=31_536_000, description="How far ahead a one-off run may be scheduled, in seconds (one year)."
)
SCHEDULE_RUN_OUTPUT_RETENTION_DAYS: int = Field(default=90, description="Days scheduled-run output is kept.")