Skip to content

[T-042b] Stop rules, auto-pause and in-app alerts (INFRA_UNHEALTHY, NO_WORKERS, DISK_LOW, GP_FALLBACK_REPEATED) #87

Closed

Description

@CodewithJha

Task T-042b · Milestone M3 — Oracles + runner + store · Size S · Priority P1 · Epic #3

Implements FR-RUN-002 · NFR-OBS-001

Branch feat/t-042b-stop-rules-auto-pause-and — one task = one branch = one PR (doc 32 §6)

Summary

Implement campaign stop rules (budget, max_modes, max_wall_s) and the auto-pause/alert policies of doc 21 §5.5, emitting alert SSE events.

Context / motivation

Unattended overnight campaigns (journey J1) must stop wasting compute when infrastructure breaks.

Scope

In scope

  • runner/stop_rules.py, runner/alerts.py.
  • Auto-pause when invalid ratio > auto_pause.invalid_ratio after min_runs, or max_consecutive_invalid reached.
  • NO_WORKERS after 60 s without a worker for the backend (make the 60 s a settings key), DISK_LOW below storage.min_free_gb, GP_FALLBACK_REPEATED after ≥ 3 consecutive fallbacks (settings key).

Implementation guidance

  • Rules are small pure predicates over campaign counters (Specification pattern).
  • Standards: respect the layering contracts (doc 16 §2) and conventions in doc 34; no hard-coded tunables — thresholds/defaults come from typed settings (doc 27); no magic numbers (ruff PLR2004); public APIs typed (mypy strict) and documented.

Configuration keys

From the configuration reference (doc 27). Keys marked (new) must be added to the typed settings models and appear in the generated reference (T-003c).

  • runner.auto_pause.invalid_ratio
  • runner.auto_pause.min_runs
  • runner.auto_pause.max_consecutive_invalid
  • storage.min_free_gb
  • runner.alerts.no_workers_after_s (new)
  • runner.alerts.gp_fallback_repeat (new)

Acceptance criteria

  • Fake-clock tests for every rule.
  • Auto-pause sets status_reason and emits an alert event.
  • Runbook RB-01/RB-07/RB-08 reference the same codes.
  • Tests listed below added and green in CI; coverage of new code meets the gate in doc 18 §3.
  • Docs, config reference and CHANGELOG Unreleased updated where behaviour, keys or interfaces changed.
  • Definition of Done (doc 32 §3) satisfied.

Tests required

  • tests/unit/runner/test_stop_rules.py, test_alerts.py.

Dependencies

Blocked by: #85 (T-041a), #63 (T-011c)

Blocks: no other task (leaf)

Parallelization notes

Files / paths owned by this task — avoid editing other paths; shared files (pyproject.toml entry points, cli/main.py, api/routers/__init__.py, router.tsx, docker/compose.yaml, ci.yml) are append-only:

  • backend/src/roboprobe/runner/stop_rules.py
  • backend/src/roboprobe/runner/alerts.py

Independent modules.

Definition of Done

Per doc 32 §3 and AGENTS.md §5: lint, format, mypy strict and import-linter green; tests added and passing; docs updated; PR template completed with Closes #<this issue>; Conventional Commit messages referencing T-042b (doc 16 §6); commits authored only by the repository owner identity (AGENTS.md §4); CI green; reviewer checklist (doc 32 §5.1) satisfied.

References

Design docs: doc 21 §5.5 · doc 14 §3 · doc 30 §RB-01 · doc 30 §RB-07 · doc 30 §RB-08 · doc 27 §4.4

Requirements: FR-RUN-002 · NFR-OBS-001 (traceability: doc 28)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:observabilityLogging, metrics, tracingarea:runnerQueue, workers, campaign orchestrationmilestone:M3M3 — Oracles + runner + storepriority:P1Required for milestone exitsize:S<= 1 daytaskChild task of a milestone epictype:featureNew functionality

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions